diff mbox series

ubifs: Allow to silence debug dumps

Message ID 20220807192709.21717-1-pali@kernel.org
State Accepted
Delegated to: Heiko Schocher
Headers show
Series ubifs: Allow to silence debug dumps | expand

Commit Message

Pali Rohár Aug. 7, 2022, 7:27 p.m. UTC
Debug dump logs are not always required. Add a new config option
UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
when enabled this will decrease size of U-Boot binary by 11 kB.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 fs/ubifs/Kconfig |  8 ++++++++
 fs/ubifs/debug.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

Comments

Tony Dinh Aug. 7, 2022, 10:30 p.m. UTC | #1
Hi Pali,

On Sun, Aug 7, 2022 at 12:27 PM Pali Rohár <pali@kernel.org> wrote:
>
> Debug dump logs are not always required. Add a new config option
> UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
> when enabled this will decrease size of U-Boot binary by 11 kB.

Great patch! I had a hunch that we could cut down the binary size of
the Kirkwood boards by doing something about this ubifs debug.c, but
was not sure how to do it properly.

I rebuilt with this patch for a few Kirkwood boxes (Sheevaplug, Pogo
V4, GoFlexHome, Zyxel NSA310S),  and each was reduced by 10 KB (with
CONFIG_SYS_THUMB_BUILD=y).  I also ran a regression test booting with
UBIFS on the NSA310S board.

Tested-by: Tony Dinh <mibodhi@gmail.com>

Thanks,
Tony

>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
>  fs/ubifs/Kconfig |  8 ++++++++
>  fs/ubifs/debug.c | 28 ++++++++++++++++++++++++++++
>  2 files changed, 36 insertions(+)
>
> diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
> index 9da35b8a3794..949b28841194 100644
> --- a/fs/ubifs/Kconfig
> +++ b/fs/ubifs/Kconfig
> @@ -4,3 +4,11 @@ config UBIFS_SILENCE_MSG
>         help
>           Make the verbose messages from UBIFS stop printing. This leaves
>           warnings and errors enabled.
> +
> +config UBIFS_SILENCE_DEBUG_DUMP
> +       bool "UBIFS silence debug dumps"
> +       default y if UBIFS_SILENCE_MSG
> +       default n
> +       help
> +         Make the debug dumps from UBIFS stop printing.
> +         This decreases size of U-Boot binary.
> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> index 2ff8f1a5f9b1..bede7d01cab0 100644
> --- a/fs/ubifs/debug.c
> +++ b/fs/ubifs/debug.c
> @@ -35,6 +35,7 @@
>  static DEFINE_SPINLOCK(dbg_lock);
>  #endif
>
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  static const char *get_key_fmt(int fmt)
>  {
>         switch (fmt) {
> @@ -230,6 +231,7 @@ static void dump_ch(const struct ubifs_ch *ch)
>                (unsigned long long)le64_to_cpu(ch->sqnum));
>         pr_err("\tlen            %u\n", le32_to_cpu(ch->len));
>  }
> +#endif
>
>  void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
>  {
> @@ -303,6 +305,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
>
>  void ubifs_dump_node(const struct ubifs_info *c, const void *node)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         int i, n;
>         union ubifs_key key;
>         const struct ubifs_ch *ch = node;
> @@ -546,10 +549,12 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
>                        (int)ch->node_type);
>         }
>         spin_unlock(&dbg_lock);
> +#endif
>  }
>
>  void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         spin_lock(&dbg_lock);
>         pr_err("Budgeting request: new_ino %d, dirtied_ino %d\n",
>                req->new_ino, req->dirtied_ino);
> @@ -563,10 +568,12 @@ void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
>         pr_err("\tdata_growth %d dd_growth     %d\n",
>                req->data_growth, req->dd_growth);
>         spin_unlock(&dbg_lock);
> +#endif
>  }
>
>  void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         spin_lock(&dbg_lock);
>         pr_err("(pid %d) Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
>                current->pid, lst->empty_lebs, lst->idx_lebs);
> @@ -575,6 +582,7 @@ void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
>         pr_err("\ttotal_used %lld, total_dark %lld, total_dead %lld\n",
>                lst->total_used, lst->total_dark, lst->total_dead);
>         spin_unlock(&dbg_lock);
> +#endif
>  }
>
>  #ifndef __UBOOT__
> @@ -653,6 +661,7 @@ void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
>
>  void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         int i, spc, dark = 0, dead = 0;
>         struct rb_node *rb;
>         struct ubifs_bud *bud;
> @@ -740,6 +749,7 @@ void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
>         if (lp->lnum == c->gc_lnum)
>                 pr_cont(", GC LEB");
>         pr_cont(")\n");
> +#endif
>  }
>
>  void ubifs_dump_lprops(struct ubifs_info *c)
> @@ -766,6 +776,7 @@ void ubifs_dump_lprops(struct ubifs_info *c)
>
>  void ubifs_dump_lpt_info(struct ubifs_info *c)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         int i;
>
>         spin_lock(&dbg_lock);
> @@ -800,11 +811,13 @@ void ubifs_dump_lpt_info(struct ubifs_info *c)
>                        i + c->lpt_first, c->ltab[i].free, c->ltab[i].dirty,
>                        c->ltab[i].tgc, c->ltab[i].cmt);
>         spin_unlock(&dbg_lock);
> +#endif
>  }
>
>  void ubifs_dump_sleb(const struct ubifs_info *c,
>                      const struct ubifs_scan_leb *sleb, int offs)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         struct ubifs_scan_node *snod;
>
>         pr_err("(pid %d) start dumping scanned data from LEB %d:%d\n",
> @@ -816,10 +829,12 @@ void ubifs_dump_sleb(const struct ubifs_info *c,
>                        sleb->lnum, snod->offs, snod->len);
>                 ubifs_dump_node(c, snod->node);
>         }
> +#endif
>  }
>
>  void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         struct ubifs_scan_leb *sleb;
>         struct ubifs_scan_node *snod;
>         void *buf;
> @@ -854,11 +869,13 @@ void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
>  out:
>         vfree(buf);
>         return;
> +#endif
>  }
>
>  void ubifs_dump_znode(const struct ubifs_info *c,
>                       const struct ubifs_znode *znode)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         int n;
>         const struct ubifs_zbranch *zbr;
>         char key_buf[DBG_KEY_BUF_LEN];
> @@ -893,10 +910,12 @@ void ubifs_dump_znode(const struct ubifs_info *c,
>                                                 DBG_KEY_BUF_LEN));
>         }
>         spin_unlock(&dbg_lock);
> +#endif
>  }
>
>  void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         int i;
>
>         pr_err("(pid %d) start dumping heap cat %d (%d elements)\n",
> @@ -909,11 +928,13 @@ void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
>                        lprops->dirty, lprops->flags);
>         }
>         pr_err("(pid %d) finish dumping heap\n", current->pid);
> +#endif
>  }
>
>  void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
>                       struct ubifs_nnode *parent, int iip)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         int i;
>
>         pr_err("(pid %d) dumping pnode:\n", current->pid);
> @@ -927,10 +948,12 @@ void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
>                 pr_err("\t%d: free %d dirty %d flags %d lnum %d\n",
>                        i, lp->free, lp->dirty, lp->flags, lp->lnum);
>         }
> +#endif
>  }
>
>  void ubifs_dump_tnc(struct ubifs_info *c)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         struct ubifs_znode *znode;
>         int level;
>
> @@ -948,14 +971,17 @@ void ubifs_dump_tnc(struct ubifs_info *c)
>                 znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
>         }
>         pr_err("(pid %d) finish dumping TNC tree\n", current->pid);
> +#endif
>  }
>
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
>                       void *priv)
>  {
>         ubifs_dump_znode(c, znode);
>         return 0;
>  }
> +#endif
>
>  /**
>   * ubifs_dump_index - dump the on-flash index.
> @@ -966,7 +992,9 @@ static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
>   */
>  void ubifs_dump_index(struct ubifs_info *c)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>         dbg_walk_index(c, NULL, dump_znode, NULL);
> +#endif
>  }
>
>  #ifndef __UBOOT__
> --
> 2.20.1
>
Pali Rohár Aug. 7, 2022, 10:54 p.m. UTC | #2
On Sunday 07 August 2022 15:30:33 Tony Dinh wrote:
> Hi Pali,
> 
> On Sun, Aug 7, 2022 at 12:27 PM Pali Rohár <pali@kernel.org> wrote:
> >
> > Debug dump logs are not always required. Add a new config option
> > UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
> > when enabled this will decrease size of U-Boot binary by 11 kB.
> 
> Great patch! I had a hunch that we could cut down the binary size of
> the Kirkwood boards by doing something about this ubifs debug.c, but
> was not sure how to do it properly.

Wow, I'm surprised that there are other boards which needs ubifs support
in u-boot.

Anyway, another option for decreasing u-boot size is to enable LTO
support or optimize inlining option.

> I rebuilt with this patch for a few Kirkwood boxes (Sheevaplug, Pogo
> V4, GoFlexHome, Zyxel NSA310S),  and each was reduced by 10 KB (with
> CONFIG_SYS_THUMB_BUILD=y).  I also ran a regression test booting with
> UBIFS on the NSA310S board.
> 
> Tested-by: Tony Dinh <mibodhi@gmail.com>
> 
> Thanks,
> Tony
> 
> >
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > ---
> >  fs/ubifs/Kconfig |  8 ++++++++
> >  fs/ubifs/debug.c | 28 ++++++++++++++++++++++++++++
> >  2 files changed, 36 insertions(+)
> >
> > diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
> > index 9da35b8a3794..949b28841194 100644
> > --- a/fs/ubifs/Kconfig
> > +++ b/fs/ubifs/Kconfig
> > @@ -4,3 +4,11 @@ config UBIFS_SILENCE_MSG
> >         help
> >           Make the verbose messages from UBIFS stop printing. This leaves
> >           warnings and errors enabled.
> > +
> > +config UBIFS_SILENCE_DEBUG_DUMP
> > +       bool "UBIFS silence debug dumps"
> > +       default y if UBIFS_SILENCE_MSG
> > +       default n
> > +       help
> > +         Make the debug dumps from UBIFS stop printing.
> > +         This decreases size of U-Boot binary.
> > diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> > index 2ff8f1a5f9b1..bede7d01cab0 100644
> > --- a/fs/ubifs/debug.c
> > +++ b/fs/ubifs/debug.c
> > @@ -35,6 +35,7 @@
> >  static DEFINE_SPINLOCK(dbg_lock);
> >  #endif
> >
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  static const char *get_key_fmt(int fmt)
> >  {
> >         switch (fmt) {
> > @@ -230,6 +231,7 @@ static void dump_ch(const struct ubifs_ch *ch)
> >                (unsigned long long)le64_to_cpu(ch->sqnum));
> >         pr_err("\tlen            %u\n", le32_to_cpu(ch->len));
> >  }
> > +#endif
> >
> >  void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> >  {
> > @@ -303,6 +305,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> >
> >  void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         int i, n;
> >         union ubifs_key key;
> >         const struct ubifs_ch *ch = node;
> > @@ -546,10 +549,12 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> >                        (int)ch->node_type);
> >         }
> >         spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >
> >  void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         spin_lock(&dbg_lock);
> >         pr_err("Budgeting request: new_ino %d, dirtied_ino %d\n",
> >                req->new_ino, req->dirtied_ino);
> > @@ -563,10 +568,12 @@ void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> >         pr_err("\tdata_growth %d dd_growth     %d\n",
> >                req->data_growth, req->dd_growth);
> >         spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >
> >  void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         spin_lock(&dbg_lock);
> >         pr_err("(pid %d) Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
> >                current->pid, lst->empty_lebs, lst->idx_lebs);
> > @@ -575,6 +582,7 @@ void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> >         pr_err("\ttotal_used %lld, total_dark %lld, total_dead %lld\n",
> >                lst->total_used, lst->total_dark, lst->total_dead);
> >         spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >
> >  #ifndef __UBOOT__
> > @@ -653,6 +661,7 @@ void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
> >
> >  void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         int i, spc, dark = 0, dead = 0;
> >         struct rb_node *rb;
> >         struct ubifs_bud *bud;
> > @@ -740,6 +749,7 @@ void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> >         if (lp->lnum == c->gc_lnum)
> >                 pr_cont(", GC LEB");
> >         pr_cont(")\n");
> > +#endif
> >  }
> >
> >  void ubifs_dump_lprops(struct ubifs_info *c)
> > @@ -766,6 +776,7 @@ void ubifs_dump_lprops(struct ubifs_info *c)
> >
> >  void ubifs_dump_lpt_info(struct ubifs_info *c)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         int i;
> >
> >         spin_lock(&dbg_lock);
> > @@ -800,11 +811,13 @@ void ubifs_dump_lpt_info(struct ubifs_info *c)
> >                        i + c->lpt_first, c->ltab[i].free, c->ltab[i].dirty,
> >                        c->ltab[i].tgc, c->ltab[i].cmt);
> >         spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >
> >  void ubifs_dump_sleb(const struct ubifs_info *c,
> >                      const struct ubifs_scan_leb *sleb, int offs)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         struct ubifs_scan_node *snod;
> >
> >         pr_err("(pid %d) start dumping scanned data from LEB %d:%d\n",
> > @@ -816,10 +829,12 @@ void ubifs_dump_sleb(const struct ubifs_info *c,
> >                        sleb->lnum, snod->offs, snod->len);
> >                 ubifs_dump_node(c, snod->node);
> >         }
> > +#endif
> >  }
> >
> >  void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         struct ubifs_scan_leb *sleb;
> >         struct ubifs_scan_node *snod;
> >         void *buf;
> > @@ -854,11 +869,13 @@ void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> >  out:
> >         vfree(buf);
> >         return;
> > +#endif
> >  }
> >
> >  void ubifs_dump_znode(const struct ubifs_info *c,
> >                       const struct ubifs_znode *znode)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         int n;
> >         const struct ubifs_zbranch *zbr;
> >         char key_buf[DBG_KEY_BUF_LEN];
> > @@ -893,10 +910,12 @@ void ubifs_dump_znode(const struct ubifs_info *c,
> >                                                 DBG_KEY_BUF_LEN));
> >         }
> >         spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >
> >  void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         int i;
> >
> >         pr_err("(pid %d) start dumping heap cat %d (%d elements)\n",
> > @@ -909,11 +928,13 @@ void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> >                        lprops->dirty, lprops->flags);
> >         }
> >         pr_err("(pid %d) finish dumping heap\n", current->pid);
> > +#endif
> >  }
> >
> >  void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> >                       struct ubifs_nnode *parent, int iip)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         int i;
> >
> >         pr_err("(pid %d) dumping pnode:\n", current->pid);
> > @@ -927,10 +948,12 @@ void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> >                 pr_err("\t%d: free %d dirty %d flags %d lnum %d\n",
> >                        i, lp->free, lp->dirty, lp->flags, lp->lnum);
> >         }
> > +#endif
> >  }
> >
> >  void ubifs_dump_tnc(struct ubifs_info *c)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         struct ubifs_znode *znode;
> >         int level;
> >
> > @@ -948,14 +971,17 @@ void ubifs_dump_tnc(struct ubifs_info *c)
> >                 znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
> >         }
> >         pr_err("(pid %d) finish dumping TNC tree\n", current->pid);
> > +#endif
> >  }
> >
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> >                       void *priv)
> >  {
> >         ubifs_dump_znode(c, znode);
> >         return 0;
> >  }
> > +#endif
> >
> >  /**
> >   * ubifs_dump_index - dump the on-flash index.
> > @@ -966,7 +992,9 @@ static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> >   */
> >  void ubifs_dump_index(struct ubifs_info *c)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >         dbg_walk_index(c, NULL, dump_znode, NULL);
> > +#endif
> >  }
> >
> >  #ifndef __UBOOT__
> > --
> > 2.20.1
> >
Tony Dinh Aug. 7, 2022, 11:19 p.m. UTC | #3
Hi Pali,

On Sun, Aug 7, 2022 at 3:54 PM Pali Rohár <pali@kernel.org> wrote:
>
> On Sunday 07 August 2022 15:30:33 Tony Dinh wrote:
> > Hi Pali,
> >
> > On Sun, Aug 7, 2022 at 12:27 PM Pali Rohár <pali@kernel.org> wrote:
> > >
> > > Debug dump logs are not always required. Add a new config option
> > > UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
> > > when enabled this will decrease size of U-Boot binary by 11 kB.
> >
> > Great patch! I had a hunch that we could cut down the binary size of
> > the Kirkwood boards by doing something about this ubifs debug.c, but
> > was not sure how to do it properly.
>
> Wow, I'm surprised that there are other boards which needs ubifs support
> in u-boot.

Indeed, there are quite a few Kirkwood boards that run OpenWrt on
UBIFS. Also, keeping u-boot binary size under 512K is important for
those boards. IOW, ability to do u-boot upgrade for boxes running
Debian, Arch and OpenWrt distros without changing mtdparts and
installation script.

> Anyway, another option for decreasing u-boot size is to enable LTO
> support or optimize inlining option.

Cool!

Thanks,
Tony


>
> > I rebuilt with this patch for a few Kirkwood boxes (Sheevaplug, Pogo
> > V4, GoFlexHome, Zyxel NSA310S),  and each was reduced by 10 KB (with
> > CONFIG_SYS_THUMB_BUILD=y).  I also ran a regression test booting with
> > UBIFS on the NSA310S board.
> >
> > Tested-by: Tony Dinh <mibodhi@gmail.com>
> >
> > Thanks,
> > Tony
> >
> > >
> > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > ---
> > >  fs/ubifs/Kconfig |  8 ++++++++
> > >  fs/ubifs/debug.c | 28 ++++++++++++++++++++++++++++
> > >  2 files changed, 36 insertions(+)
> > >
> > > diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
> > > index 9da35b8a3794..949b28841194 100644
> > > --- a/fs/ubifs/Kconfig
> > > +++ b/fs/ubifs/Kconfig
> > > @@ -4,3 +4,11 @@ config UBIFS_SILENCE_MSG
> > >         help
> > >           Make the verbose messages from UBIFS stop printing. This leaves
> > >           warnings and errors enabled.
> > > +
> > > +config UBIFS_SILENCE_DEBUG_DUMP
> > > +       bool "UBIFS silence debug dumps"
> > > +       default y if UBIFS_SILENCE_MSG
> > > +       default n
> > > +       help
> > > +         Make the debug dumps from UBIFS stop printing.
> > > +         This decreases size of U-Boot binary.
> > > diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> > > index 2ff8f1a5f9b1..bede7d01cab0 100644
> > > --- a/fs/ubifs/debug.c
> > > +++ b/fs/ubifs/debug.c
> > > @@ -35,6 +35,7 @@
> > >  static DEFINE_SPINLOCK(dbg_lock);
> > >  #endif
> > >
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  static const char *get_key_fmt(int fmt)
> > >  {
> > >         switch (fmt) {
> > > @@ -230,6 +231,7 @@ static void dump_ch(const struct ubifs_ch *ch)
> > >                (unsigned long long)le64_to_cpu(ch->sqnum));
> > >         pr_err("\tlen            %u\n", le32_to_cpu(ch->len));
> > >  }
> > > +#endif
> > >
> > >  void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> > >  {
> > > @@ -303,6 +305,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> > >
> > >  void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         int i, n;
> > >         union ubifs_key key;
> > >         const struct ubifs_ch *ch = node;
> > > @@ -546,10 +549,12 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> > >                        (int)ch->node_type);
> > >         }
> > >         spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         spin_lock(&dbg_lock);
> > >         pr_err("Budgeting request: new_ino %d, dirtied_ino %d\n",
> > >                req->new_ino, req->dirtied_ino);
> > > @@ -563,10 +568,12 @@ void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> > >         pr_err("\tdata_growth %d dd_growth     %d\n",
> > >                req->data_growth, req->dd_growth);
> > >         spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         spin_lock(&dbg_lock);
> > >         pr_err("(pid %d) Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
> > >                current->pid, lst->empty_lebs, lst->idx_lebs);
> > > @@ -575,6 +582,7 @@ void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> > >         pr_err("\ttotal_used %lld, total_dark %lld, total_dead %lld\n",
> > >                lst->total_used, lst->total_dark, lst->total_dead);
> > >         spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >
> > >  #ifndef __UBOOT__
> > > @@ -653,6 +661,7 @@ void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
> > >
> > >  void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         int i, spc, dark = 0, dead = 0;
> > >         struct rb_node *rb;
> > >         struct ubifs_bud *bud;
> > > @@ -740,6 +749,7 @@ void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> > >         if (lp->lnum == c->gc_lnum)
> > >                 pr_cont(", GC LEB");
> > >         pr_cont(")\n");
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_lprops(struct ubifs_info *c)
> > > @@ -766,6 +776,7 @@ void ubifs_dump_lprops(struct ubifs_info *c)
> > >
> > >  void ubifs_dump_lpt_info(struct ubifs_info *c)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         int i;
> > >
> > >         spin_lock(&dbg_lock);
> > > @@ -800,11 +811,13 @@ void ubifs_dump_lpt_info(struct ubifs_info *c)
> > >                        i + c->lpt_first, c->ltab[i].free, c->ltab[i].dirty,
> > >                        c->ltab[i].tgc, c->ltab[i].cmt);
> > >         spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_sleb(const struct ubifs_info *c,
> > >                      const struct ubifs_scan_leb *sleb, int offs)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         struct ubifs_scan_node *snod;
> > >
> > >         pr_err("(pid %d) start dumping scanned data from LEB %d:%d\n",
> > > @@ -816,10 +829,12 @@ void ubifs_dump_sleb(const struct ubifs_info *c,
> > >                        sleb->lnum, snod->offs, snod->len);
> > >                 ubifs_dump_node(c, snod->node);
> > >         }
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         struct ubifs_scan_leb *sleb;
> > >         struct ubifs_scan_node *snod;
> > >         void *buf;
> > > @@ -854,11 +869,13 @@ void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> > >  out:
> > >         vfree(buf);
> > >         return;
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_znode(const struct ubifs_info *c,
> > >                       const struct ubifs_znode *znode)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         int n;
> > >         const struct ubifs_zbranch *zbr;
> > >         char key_buf[DBG_KEY_BUF_LEN];
> > > @@ -893,10 +910,12 @@ void ubifs_dump_znode(const struct ubifs_info *c,
> > >                                                 DBG_KEY_BUF_LEN));
> > >         }
> > >         spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         int i;
> > >
> > >         pr_err("(pid %d) start dumping heap cat %d (%d elements)\n",
> > > @@ -909,11 +928,13 @@ void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> > >                        lprops->dirty, lprops->flags);
> > >         }
> > >         pr_err("(pid %d) finish dumping heap\n", current->pid);
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> > >                       struct ubifs_nnode *parent, int iip)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         int i;
> > >
> > >         pr_err("(pid %d) dumping pnode:\n", current->pid);
> > > @@ -927,10 +948,12 @@ void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> > >                 pr_err("\t%d: free %d dirty %d flags %d lnum %d\n",
> > >                        i, lp->free, lp->dirty, lp->flags, lp->lnum);
> > >         }
> > > +#endif
> > >  }
> > >
> > >  void ubifs_dump_tnc(struct ubifs_info *c)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         struct ubifs_znode *znode;
> > >         int level;
> > >
> > > @@ -948,14 +971,17 @@ void ubifs_dump_tnc(struct ubifs_info *c)
> > >                 znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
> > >         }
> > >         pr_err("(pid %d) finish dumping TNC tree\n", current->pid);
> > > +#endif
> > >  }
> > >
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> > >                       void *priv)
> > >  {
> > >         ubifs_dump_znode(c, znode);
> > >         return 0;
> > >  }
> > > +#endif
> > >
> > >  /**
> > >   * ubifs_dump_index - dump the on-flash index.
> > > @@ -966,7 +992,9 @@ static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> > >   */
> > >  void ubifs_dump_index(struct ubifs_info *c)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >         dbg_walk_index(c, NULL, dump_znode, NULL);
> > > +#endif
> > >  }
> > >
> > >  #ifndef __UBOOT__
> > > --
> > > 2.20.1
> > >
Pali Rohár Aug. 25, 2022, 1:53 p.m. UTC | #4
PING? Who can review and take this patch? It is needed for more boards
due to increasing size of u-boot binary.

On Sunday 07 August 2022 21:27:09 Pali Rohár wrote:
> Debug dump logs are not always required. Add a new config option
> UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
> when enabled this will decrease size of U-Boot binary by 11 kB.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> ---
>  fs/ubifs/Kconfig |  8 ++++++++
>  fs/ubifs/debug.c | 28 ++++++++++++++++++++++++++++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
> index 9da35b8a3794..949b28841194 100644
> --- a/fs/ubifs/Kconfig
> +++ b/fs/ubifs/Kconfig
> @@ -4,3 +4,11 @@ config UBIFS_SILENCE_MSG
>  	help
>  	  Make the verbose messages from UBIFS stop printing. This leaves
>  	  warnings and errors enabled.
> +
> +config UBIFS_SILENCE_DEBUG_DUMP
> +	bool "UBIFS silence debug dumps"
> +	default y if UBIFS_SILENCE_MSG
> +	default n
> +	help
> +	  Make the debug dumps from UBIFS stop printing.
> +	  This decreases size of U-Boot binary.
> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> index 2ff8f1a5f9b1..bede7d01cab0 100644
> --- a/fs/ubifs/debug.c
> +++ b/fs/ubifs/debug.c
> @@ -35,6 +35,7 @@
>  static DEFINE_SPINLOCK(dbg_lock);
>  #endif
>  
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  static const char *get_key_fmt(int fmt)
>  {
>  	switch (fmt) {
> @@ -230,6 +231,7 @@ static void dump_ch(const struct ubifs_ch *ch)
>  	       (unsigned long long)le64_to_cpu(ch->sqnum));
>  	pr_err("\tlen            %u\n", le32_to_cpu(ch->len));
>  }
> +#endif
>  
>  void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
>  {
> @@ -303,6 +305,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
>  
>  void ubifs_dump_node(const struct ubifs_info *c, const void *node)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	int i, n;
>  	union ubifs_key key;
>  	const struct ubifs_ch *ch = node;
> @@ -546,10 +549,12 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
>  		       (int)ch->node_type);
>  	}
>  	spin_unlock(&dbg_lock);
> +#endif
>  }
>  
>  void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	spin_lock(&dbg_lock);
>  	pr_err("Budgeting request: new_ino %d, dirtied_ino %d\n",
>  	       req->new_ino, req->dirtied_ino);
> @@ -563,10 +568,12 @@ void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
>  	pr_err("\tdata_growth %d dd_growth     %d\n",
>  	       req->data_growth, req->dd_growth);
>  	spin_unlock(&dbg_lock);
> +#endif
>  }
>  
>  void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	spin_lock(&dbg_lock);
>  	pr_err("(pid %d) Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
>  	       current->pid, lst->empty_lebs, lst->idx_lebs);
> @@ -575,6 +582,7 @@ void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
>  	pr_err("\ttotal_used %lld, total_dark %lld, total_dead %lld\n",
>  	       lst->total_used, lst->total_dark, lst->total_dead);
>  	spin_unlock(&dbg_lock);
> +#endif
>  }
>  
>  #ifndef __UBOOT__
> @@ -653,6 +661,7 @@ void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
>  
>  void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	int i, spc, dark = 0, dead = 0;
>  	struct rb_node *rb;
>  	struct ubifs_bud *bud;
> @@ -740,6 +749,7 @@ void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
>  	if (lp->lnum == c->gc_lnum)
>  		pr_cont(", GC LEB");
>  	pr_cont(")\n");
> +#endif
>  }
>  
>  void ubifs_dump_lprops(struct ubifs_info *c)
> @@ -766,6 +776,7 @@ void ubifs_dump_lprops(struct ubifs_info *c)
>  
>  void ubifs_dump_lpt_info(struct ubifs_info *c)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	int i;
>  
>  	spin_lock(&dbg_lock);
> @@ -800,11 +811,13 @@ void ubifs_dump_lpt_info(struct ubifs_info *c)
>  		       i + c->lpt_first, c->ltab[i].free, c->ltab[i].dirty,
>  		       c->ltab[i].tgc, c->ltab[i].cmt);
>  	spin_unlock(&dbg_lock);
> +#endif
>  }
>  
>  void ubifs_dump_sleb(const struct ubifs_info *c,
>  		     const struct ubifs_scan_leb *sleb, int offs)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	struct ubifs_scan_node *snod;
>  
>  	pr_err("(pid %d) start dumping scanned data from LEB %d:%d\n",
> @@ -816,10 +829,12 @@ void ubifs_dump_sleb(const struct ubifs_info *c,
>  		       sleb->lnum, snod->offs, snod->len);
>  		ubifs_dump_node(c, snod->node);
>  	}
> +#endif
>  }
>  
>  void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	struct ubifs_scan_leb *sleb;
>  	struct ubifs_scan_node *snod;
>  	void *buf;
> @@ -854,11 +869,13 @@ void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
>  out:
>  	vfree(buf);
>  	return;
> +#endif
>  }
>  
>  void ubifs_dump_znode(const struct ubifs_info *c,
>  		      const struct ubifs_znode *znode)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	int n;
>  	const struct ubifs_zbranch *zbr;
>  	char key_buf[DBG_KEY_BUF_LEN];
> @@ -893,10 +910,12 @@ void ubifs_dump_znode(const struct ubifs_info *c,
>  						DBG_KEY_BUF_LEN));
>  	}
>  	spin_unlock(&dbg_lock);
> +#endif
>  }
>  
>  void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	int i;
>  
>  	pr_err("(pid %d) start dumping heap cat %d (%d elements)\n",
> @@ -909,11 +928,13 @@ void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
>  		       lprops->dirty, lprops->flags);
>  	}
>  	pr_err("(pid %d) finish dumping heap\n", current->pid);
> +#endif
>  }
>  
>  void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
>  		      struct ubifs_nnode *parent, int iip)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	int i;
>  
>  	pr_err("(pid %d) dumping pnode:\n", current->pid);
> @@ -927,10 +948,12 @@ void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
>  		pr_err("\t%d: free %d dirty %d flags %d lnum %d\n",
>  		       i, lp->free, lp->dirty, lp->flags, lp->lnum);
>  	}
> +#endif
>  }
>  
>  void ubifs_dump_tnc(struct ubifs_info *c)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	struct ubifs_znode *znode;
>  	int level;
>  
> @@ -948,14 +971,17 @@ void ubifs_dump_tnc(struct ubifs_info *c)
>  		znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
>  	}
>  	pr_err("(pid %d) finish dumping TNC tree\n", current->pid);
> +#endif
>  }
>  
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
>  		      void *priv)
>  {
>  	ubifs_dump_znode(c, znode);
>  	return 0;
>  }
> +#endif
>  
>  /**
>   * ubifs_dump_index - dump the on-flash index.
> @@ -966,7 +992,9 @@ static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
>   */
>  void ubifs_dump_index(struct ubifs_info *c)
>  {
> +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
>  	dbg_walk_index(c, NULL, dump_znode, NULL);
> +#endif
>  }
>  
>  #ifndef __UBOOT__
> -- 
> 2.20.1
>
Pali Rohár Oct. 9, 2022, 11:30 a.m. UTC | #5
PING again after more than one month.

On Thursday 25 August 2022 15:53:32 Pali Rohár wrote:
> PING? Who can review and take this patch? It is needed for more boards
> due to increasing size of u-boot binary.
> 
> On Sunday 07 August 2022 21:27:09 Pali Rohár wrote:
> > Debug dump logs are not always required. Add a new config option
> > UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
> > when enabled this will decrease size of U-Boot binary by 11 kB.
> > 
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> > ---
> >  fs/ubifs/Kconfig |  8 ++++++++
> >  fs/ubifs/debug.c | 28 ++++++++++++++++++++++++++++
> >  2 files changed, 36 insertions(+)
> > 
> > diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
> > index 9da35b8a3794..949b28841194 100644
> > --- a/fs/ubifs/Kconfig
> > +++ b/fs/ubifs/Kconfig
> > @@ -4,3 +4,11 @@ config UBIFS_SILENCE_MSG
> >  	help
> >  	  Make the verbose messages from UBIFS stop printing. This leaves
> >  	  warnings and errors enabled.
> > +
> > +config UBIFS_SILENCE_DEBUG_DUMP
> > +	bool "UBIFS silence debug dumps"
> > +	default y if UBIFS_SILENCE_MSG
> > +	default n
> > +	help
> > +	  Make the debug dumps from UBIFS stop printing.
> > +	  This decreases size of U-Boot binary.
> > diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> > index 2ff8f1a5f9b1..bede7d01cab0 100644
> > --- a/fs/ubifs/debug.c
> > +++ b/fs/ubifs/debug.c
> > @@ -35,6 +35,7 @@
> >  static DEFINE_SPINLOCK(dbg_lock);
> >  #endif
> >  
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  static const char *get_key_fmt(int fmt)
> >  {
> >  	switch (fmt) {
> > @@ -230,6 +231,7 @@ static void dump_ch(const struct ubifs_ch *ch)
> >  	       (unsigned long long)le64_to_cpu(ch->sqnum));
> >  	pr_err("\tlen            %u\n", le32_to_cpu(ch->len));
> >  }
> > +#endif
> >  
> >  void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> >  {
> > @@ -303,6 +305,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> >  
> >  void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	int i, n;
> >  	union ubifs_key key;
> >  	const struct ubifs_ch *ch = node;
> > @@ -546,10 +549,12 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> >  		       (int)ch->node_type);
> >  	}
> >  	spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >  
> >  void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	spin_lock(&dbg_lock);
> >  	pr_err("Budgeting request: new_ino %d, dirtied_ino %d\n",
> >  	       req->new_ino, req->dirtied_ino);
> > @@ -563,10 +568,12 @@ void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> >  	pr_err("\tdata_growth %d dd_growth     %d\n",
> >  	       req->data_growth, req->dd_growth);
> >  	spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >  
> >  void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	spin_lock(&dbg_lock);
> >  	pr_err("(pid %d) Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
> >  	       current->pid, lst->empty_lebs, lst->idx_lebs);
> > @@ -575,6 +582,7 @@ void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> >  	pr_err("\ttotal_used %lld, total_dark %lld, total_dead %lld\n",
> >  	       lst->total_used, lst->total_dark, lst->total_dead);
> >  	spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >  
> >  #ifndef __UBOOT__
> > @@ -653,6 +661,7 @@ void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
> >  
> >  void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	int i, spc, dark = 0, dead = 0;
> >  	struct rb_node *rb;
> >  	struct ubifs_bud *bud;
> > @@ -740,6 +749,7 @@ void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> >  	if (lp->lnum == c->gc_lnum)
> >  		pr_cont(", GC LEB");
> >  	pr_cont(")\n");
> > +#endif
> >  }
> >  
> >  void ubifs_dump_lprops(struct ubifs_info *c)
> > @@ -766,6 +776,7 @@ void ubifs_dump_lprops(struct ubifs_info *c)
> >  
> >  void ubifs_dump_lpt_info(struct ubifs_info *c)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	int i;
> >  
> >  	spin_lock(&dbg_lock);
> > @@ -800,11 +811,13 @@ void ubifs_dump_lpt_info(struct ubifs_info *c)
> >  		       i + c->lpt_first, c->ltab[i].free, c->ltab[i].dirty,
> >  		       c->ltab[i].tgc, c->ltab[i].cmt);
> >  	spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >  
> >  void ubifs_dump_sleb(const struct ubifs_info *c,
> >  		     const struct ubifs_scan_leb *sleb, int offs)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	struct ubifs_scan_node *snod;
> >  
> >  	pr_err("(pid %d) start dumping scanned data from LEB %d:%d\n",
> > @@ -816,10 +829,12 @@ void ubifs_dump_sleb(const struct ubifs_info *c,
> >  		       sleb->lnum, snod->offs, snod->len);
> >  		ubifs_dump_node(c, snod->node);
> >  	}
> > +#endif
> >  }
> >  
> >  void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	struct ubifs_scan_leb *sleb;
> >  	struct ubifs_scan_node *snod;
> >  	void *buf;
> > @@ -854,11 +869,13 @@ void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> >  out:
> >  	vfree(buf);
> >  	return;
> > +#endif
> >  }
> >  
> >  void ubifs_dump_znode(const struct ubifs_info *c,
> >  		      const struct ubifs_znode *znode)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	int n;
> >  	const struct ubifs_zbranch *zbr;
> >  	char key_buf[DBG_KEY_BUF_LEN];
> > @@ -893,10 +910,12 @@ void ubifs_dump_znode(const struct ubifs_info *c,
> >  						DBG_KEY_BUF_LEN));
> >  	}
> >  	spin_unlock(&dbg_lock);
> > +#endif
> >  }
> >  
> >  void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	int i;
> >  
> >  	pr_err("(pid %d) start dumping heap cat %d (%d elements)\n",
> > @@ -909,11 +928,13 @@ void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> >  		       lprops->dirty, lprops->flags);
> >  	}
> >  	pr_err("(pid %d) finish dumping heap\n", current->pid);
> > +#endif
> >  }
> >  
> >  void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> >  		      struct ubifs_nnode *parent, int iip)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	int i;
> >  
> >  	pr_err("(pid %d) dumping pnode:\n", current->pid);
> > @@ -927,10 +948,12 @@ void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> >  		pr_err("\t%d: free %d dirty %d flags %d lnum %d\n",
> >  		       i, lp->free, lp->dirty, lp->flags, lp->lnum);
> >  	}
> > +#endif
> >  }
> >  
> >  void ubifs_dump_tnc(struct ubifs_info *c)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	struct ubifs_znode *znode;
> >  	int level;
> >  
> > @@ -948,14 +971,17 @@ void ubifs_dump_tnc(struct ubifs_info *c)
> >  		znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
> >  	}
> >  	pr_err("(pid %d) finish dumping TNC tree\n", current->pid);
> > +#endif
> >  }
> >  
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> >  		      void *priv)
> >  {
> >  	ubifs_dump_znode(c, znode);
> >  	return 0;
> >  }
> > +#endif
> >  
> >  /**
> >   * ubifs_dump_index - dump the on-flash index.
> > @@ -966,7 +992,9 @@ static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> >   */
> >  void ubifs_dump_index(struct ubifs_info *c)
> >  {
> > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> >  	dbg_walk_index(c, NULL, dump_znode, NULL);
> > +#endif
> >  }
> >  
> >  #ifndef __UBOOT__
> > -- 
> > 2.20.1
> >
Pali Rohár Nov. 1, 2022, 10:26 p.m. UTC | #6
PING again

On Sunday 09 October 2022 13:30:26 Pali Rohár wrote:
> PING again after more than one month.
> 
> On Thursday 25 August 2022 15:53:32 Pali Rohár wrote:
> > PING? Who can review and take this patch? It is needed for more boards
> > due to increasing size of u-boot binary.
> > 
> > On Sunday 07 August 2022 21:27:09 Pali Rohár wrote:
> > > Debug dump logs are not always required. Add a new config option
> > > UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
> > > when enabled this will decrease size of U-Boot binary by 11 kB.
> > > 
> > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > ---
> > >  fs/ubifs/Kconfig |  8 ++++++++
> > >  fs/ubifs/debug.c | 28 ++++++++++++++++++++++++++++
> > >  2 files changed, 36 insertions(+)
> > > 
> > > diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
> > > index 9da35b8a3794..949b28841194 100644
> > > --- a/fs/ubifs/Kconfig
> > > +++ b/fs/ubifs/Kconfig
> > > @@ -4,3 +4,11 @@ config UBIFS_SILENCE_MSG
> > >  	help
> > >  	  Make the verbose messages from UBIFS stop printing. This leaves
> > >  	  warnings and errors enabled.
> > > +
> > > +config UBIFS_SILENCE_DEBUG_DUMP
> > > +	bool "UBIFS silence debug dumps"
> > > +	default y if UBIFS_SILENCE_MSG
> > > +	default n
> > > +	help
> > > +	  Make the debug dumps from UBIFS stop printing.
> > > +	  This decreases size of U-Boot binary.
> > > diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> > > index 2ff8f1a5f9b1..bede7d01cab0 100644
> > > --- a/fs/ubifs/debug.c
> > > +++ b/fs/ubifs/debug.c
> > > @@ -35,6 +35,7 @@
> > >  static DEFINE_SPINLOCK(dbg_lock);
> > >  #endif
> > >  
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  static const char *get_key_fmt(int fmt)
> > >  {
> > >  	switch (fmt) {
> > > @@ -230,6 +231,7 @@ static void dump_ch(const struct ubifs_ch *ch)
> > >  	       (unsigned long long)le64_to_cpu(ch->sqnum));
> > >  	pr_err("\tlen            %u\n", le32_to_cpu(ch->len));
> > >  }
> > > +#endif
> > >  
> > >  void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> > >  {
> > > @@ -303,6 +305,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> > >  
> > >  void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	int i, n;
> > >  	union ubifs_key key;
> > >  	const struct ubifs_ch *ch = node;
> > > @@ -546,10 +549,12 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> > >  		       (int)ch->node_type);
> > >  	}
> > >  	spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	spin_lock(&dbg_lock);
> > >  	pr_err("Budgeting request: new_ino %d, dirtied_ino %d\n",
> > >  	       req->new_ino, req->dirtied_ino);
> > > @@ -563,10 +568,12 @@ void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> > >  	pr_err("\tdata_growth %d dd_growth     %d\n",
> > >  	       req->data_growth, req->dd_growth);
> > >  	spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	spin_lock(&dbg_lock);
> > >  	pr_err("(pid %d) Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
> > >  	       current->pid, lst->empty_lebs, lst->idx_lebs);
> > > @@ -575,6 +582,7 @@ void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> > >  	pr_err("\ttotal_used %lld, total_dark %lld, total_dead %lld\n",
> > >  	       lst->total_used, lst->total_dark, lst->total_dead);
> > >  	spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >  
> > >  #ifndef __UBOOT__
> > > @@ -653,6 +661,7 @@ void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
> > >  
> > >  void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	int i, spc, dark = 0, dead = 0;
> > >  	struct rb_node *rb;
> > >  	struct ubifs_bud *bud;
> > > @@ -740,6 +749,7 @@ void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> > >  	if (lp->lnum == c->gc_lnum)
> > >  		pr_cont(", GC LEB");
> > >  	pr_cont(")\n");
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_lprops(struct ubifs_info *c)
> > > @@ -766,6 +776,7 @@ void ubifs_dump_lprops(struct ubifs_info *c)
> > >  
> > >  void ubifs_dump_lpt_info(struct ubifs_info *c)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	int i;
> > >  
> > >  	spin_lock(&dbg_lock);
> > > @@ -800,11 +811,13 @@ void ubifs_dump_lpt_info(struct ubifs_info *c)
> > >  		       i + c->lpt_first, c->ltab[i].free, c->ltab[i].dirty,
> > >  		       c->ltab[i].tgc, c->ltab[i].cmt);
> > >  	spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_sleb(const struct ubifs_info *c,
> > >  		     const struct ubifs_scan_leb *sleb, int offs)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	struct ubifs_scan_node *snod;
> > >  
> > >  	pr_err("(pid %d) start dumping scanned data from LEB %d:%d\n",
> > > @@ -816,10 +829,12 @@ void ubifs_dump_sleb(const struct ubifs_info *c,
> > >  		       sleb->lnum, snod->offs, snod->len);
> > >  		ubifs_dump_node(c, snod->node);
> > >  	}
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	struct ubifs_scan_leb *sleb;
> > >  	struct ubifs_scan_node *snod;
> > >  	void *buf;
> > > @@ -854,11 +869,13 @@ void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> > >  out:
> > >  	vfree(buf);
> > >  	return;
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_znode(const struct ubifs_info *c,
> > >  		      const struct ubifs_znode *znode)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	int n;
> > >  	const struct ubifs_zbranch *zbr;
> > >  	char key_buf[DBG_KEY_BUF_LEN];
> > > @@ -893,10 +910,12 @@ void ubifs_dump_znode(const struct ubifs_info *c,
> > >  						DBG_KEY_BUF_LEN));
> > >  	}
> > >  	spin_unlock(&dbg_lock);
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	int i;
> > >  
> > >  	pr_err("(pid %d) start dumping heap cat %d (%d elements)\n",
> > > @@ -909,11 +928,13 @@ void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> > >  		       lprops->dirty, lprops->flags);
> > >  	}
> > >  	pr_err("(pid %d) finish dumping heap\n", current->pid);
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> > >  		      struct ubifs_nnode *parent, int iip)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	int i;
> > >  
> > >  	pr_err("(pid %d) dumping pnode:\n", current->pid);
> > > @@ -927,10 +948,12 @@ void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> > >  		pr_err("\t%d: free %d dirty %d flags %d lnum %d\n",
> > >  		       i, lp->free, lp->dirty, lp->flags, lp->lnum);
> > >  	}
> > > +#endif
> > >  }
> > >  
> > >  void ubifs_dump_tnc(struct ubifs_info *c)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	struct ubifs_znode *znode;
> > >  	int level;
> > >  
> > > @@ -948,14 +971,17 @@ void ubifs_dump_tnc(struct ubifs_info *c)
> > >  		znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
> > >  	}
> > >  	pr_err("(pid %d) finish dumping TNC tree\n", current->pid);
> > > +#endif
> > >  }
> > >  
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> > >  		      void *priv)
> > >  {
> > >  	ubifs_dump_znode(c, znode);
> > >  	return 0;
> > >  }
> > > +#endif
> > >  
> > >  /**
> > >   * ubifs_dump_index - dump the on-flash index.
> > > @@ -966,7 +992,9 @@ static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> > >   */
> > >  void ubifs_dump_index(struct ubifs_info *c)
> > >  {
> > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > >  	dbg_walk_index(c, NULL, dump_znode, NULL);
> > > +#endif
> > >  }
> > >  
> > >  #ifndef __UBOOT__
> > > -- 
> > > 2.20.1
> > >
Pali Rohár Nov. 21, 2022, 5:37 p.m. UTC | #7
+ Tom

On Tuesday 01 November 2022 23:26:37 Pali Rohár wrote:
> PING again
> 
> On Sunday 09 October 2022 13:30:26 Pali Rohár wrote:
> > PING again after more than one month.
> > 
> > On Thursday 25 August 2022 15:53:32 Pali Rohár wrote:
> > > PING? Who can review and take this patch? It is needed for more boards
> > > due to increasing size of u-boot binary.
> > > 
> > > On Sunday 07 August 2022 21:27:09 Pali Rohár wrote:
> > > > Debug dump logs are not always required. Add a new config option
> > > > UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
> > > > when enabled this will decrease size of U-Boot binary by 11 kB.
> > > > 
> > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > > ---
> > > >  fs/ubifs/Kconfig |  8 ++++++++
> > > >  fs/ubifs/debug.c | 28 ++++++++++++++++++++++++++++
> > > >  2 files changed, 36 insertions(+)
> > > > 
> > > > diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
> > > > index 9da35b8a3794..949b28841194 100644
> > > > --- a/fs/ubifs/Kconfig
> > > > +++ b/fs/ubifs/Kconfig
> > > > @@ -4,3 +4,11 @@ config UBIFS_SILENCE_MSG
> > > >  	help
> > > >  	  Make the verbose messages from UBIFS stop printing. This leaves
> > > >  	  warnings and errors enabled.
> > > > +
> > > > +config UBIFS_SILENCE_DEBUG_DUMP
> > > > +	bool "UBIFS silence debug dumps"
> > > > +	default y if UBIFS_SILENCE_MSG
> > > > +	default n
> > > > +	help
> > > > +	  Make the debug dumps from UBIFS stop printing.
> > > > +	  This decreases size of U-Boot binary.
> > > > diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> > > > index 2ff8f1a5f9b1..bede7d01cab0 100644
> > > > --- a/fs/ubifs/debug.c
> > > > +++ b/fs/ubifs/debug.c
> > > > @@ -35,6 +35,7 @@
> > > >  static DEFINE_SPINLOCK(dbg_lock);
> > > >  #endif
> > > >  
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  static const char *get_key_fmt(int fmt)
> > > >  {
> > > >  	switch (fmt) {
> > > > @@ -230,6 +231,7 @@ static void dump_ch(const struct ubifs_ch *ch)
> > > >  	       (unsigned long long)le64_to_cpu(ch->sqnum));
> > > >  	pr_err("\tlen            %u\n", le32_to_cpu(ch->len));
> > > >  }
> > > > +#endif
> > > >  
> > > >  void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> > > >  {
> > > > @@ -303,6 +305,7 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
> > > >  
> > > >  void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	int i, n;
> > > >  	union ubifs_key key;
> > > >  	const struct ubifs_ch *ch = node;
> > > > @@ -546,10 +549,12 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
> > > >  		       (int)ch->node_type);
> > > >  	}
> > > >  	spin_unlock(&dbg_lock);
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	spin_lock(&dbg_lock);
> > > >  	pr_err("Budgeting request: new_ino %d, dirtied_ino %d\n",
> > > >  	       req->new_ino, req->dirtied_ino);
> > > > @@ -563,10 +568,12 @@ void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
> > > >  	pr_err("\tdata_growth %d dd_growth     %d\n",
> > > >  	       req->data_growth, req->dd_growth);
> > > >  	spin_unlock(&dbg_lock);
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	spin_lock(&dbg_lock);
> > > >  	pr_err("(pid %d) Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
> > > >  	       current->pid, lst->empty_lebs, lst->idx_lebs);
> > > > @@ -575,6 +582,7 @@ void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
> > > >  	pr_err("\ttotal_used %lld, total_dark %lld, total_dead %lld\n",
> > > >  	       lst->total_used, lst->total_dark, lst->total_dead);
> > > >  	spin_unlock(&dbg_lock);
> > > > +#endif
> > > >  }
> > > >  
> > > >  #ifndef __UBOOT__
> > > > @@ -653,6 +661,7 @@ void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
> > > >  
> > > >  void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	int i, spc, dark = 0, dead = 0;
> > > >  	struct rb_node *rb;
> > > >  	struct ubifs_bud *bud;
> > > > @@ -740,6 +749,7 @@ void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
> > > >  	if (lp->lnum == c->gc_lnum)
> > > >  		pr_cont(", GC LEB");
> > > >  	pr_cont(")\n");
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_lprops(struct ubifs_info *c)
> > > > @@ -766,6 +776,7 @@ void ubifs_dump_lprops(struct ubifs_info *c)
> > > >  
> > > >  void ubifs_dump_lpt_info(struct ubifs_info *c)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	int i;
> > > >  
> > > >  	spin_lock(&dbg_lock);
> > > > @@ -800,11 +811,13 @@ void ubifs_dump_lpt_info(struct ubifs_info *c)
> > > >  		       i + c->lpt_first, c->ltab[i].free, c->ltab[i].dirty,
> > > >  		       c->ltab[i].tgc, c->ltab[i].cmt);
> > > >  	spin_unlock(&dbg_lock);
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_sleb(const struct ubifs_info *c,
> > > >  		     const struct ubifs_scan_leb *sleb, int offs)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	struct ubifs_scan_node *snod;
> > > >  
> > > >  	pr_err("(pid %d) start dumping scanned data from LEB %d:%d\n",
> > > > @@ -816,10 +829,12 @@ void ubifs_dump_sleb(const struct ubifs_info *c,
> > > >  		       sleb->lnum, snod->offs, snod->len);
> > > >  		ubifs_dump_node(c, snod->node);
> > > >  	}
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	struct ubifs_scan_leb *sleb;
> > > >  	struct ubifs_scan_node *snod;
> > > >  	void *buf;
> > > > @@ -854,11 +869,13 @@ void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
> > > >  out:
> > > >  	vfree(buf);
> > > >  	return;
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_znode(const struct ubifs_info *c,
> > > >  		      const struct ubifs_znode *znode)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	int n;
> > > >  	const struct ubifs_zbranch *zbr;
> > > >  	char key_buf[DBG_KEY_BUF_LEN];
> > > > @@ -893,10 +910,12 @@ void ubifs_dump_znode(const struct ubifs_info *c,
> > > >  						DBG_KEY_BUF_LEN));
> > > >  	}
> > > >  	spin_unlock(&dbg_lock);
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	int i;
> > > >  
> > > >  	pr_err("(pid %d) start dumping heap cat %d (%d elements)\n",
> > > > @@ -909,11 +928,13 @@ void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
> > > >  		       lprops->dirty, lprops->flags);
> > > >  	}
> > > >  	pr_err("(pid %d) finish dumping heap\n", current->pid);
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> > > >  		      struct ubifs_nnode *parent, int iip)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	int i;
> > > >  
> > > >  	pr_err("(pid %d) dumping pnode:\n", current->pid);
> > > > @@ -927,10 +948,12 @@ void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
> > > >  		pr_err("\t%d: free %d dirty %d flags %d lnum %d\n",
> > > >  		       i, lp->free, lp->dirty, lp->flags, lp->lnum);
> > > >  	}
> > > > +#endif
> > > >  }
> > > >  
> > > >  void ubifs_dump_tnc(struct ubifs_info *c)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	struct ubifs_znode *znode;
> > > >  	int level;
> > > >  
> > > > @@ -948,14 +971,17 @@ void ubifs_dump_tnc(struct ubifs_info *c)
> > > >  		znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
> > > >  	}
> > > >  	pr_err("(pid %d) finish dumping TNC tree\n", current->pid);
> > > > +#endif
> > > >  }
> > > >  
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> > > >  		      void *priv)
> > > >  {
> > > >  	ubifs_dump_znode(c, znode);
> > > >  	return 0;
> > > >  }
> > > > +#endif
> > > >  
> > > >  /**
> > > >   * ubifs_dump_index - dump the on-flash index.
> > > > @@ -966,7 +992,9 @@ static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
> > > >   */
> > > >  void ubifs_dump_index(struct ubifs_info *c)
> > > >  {
> > > > +#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
> > > >  	dbg_walk_index(c, NULL, dump_znode, NULL);
> > > > +#endif
> > > >  }
> > > >  
> > > >  #ifndef __UBOOT__
> > > > -- 
> > > > 2.20.1
> > > >
Tom Rini Nov. 24, 2022, 9:32 p.m. UTC | #8
On Sun, Aug 07, 2022 at 09:27:09PM +0200, Pali Rohár wrote:

> Debug dump logs are not always required. Add a new config option
> UBIFS_SILENCE_DEBUG_DUMP to silence all debug dumps. On powerpc/mpc85xx
> when enabled this will decrease size of U-Boot binary by 11 kB.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Tested-by: Tony Dinh <mibodhi@gmail.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
index 9da35b8a3794..949b28841194 100644
--- a/fs/ubifs/Kconfig
+++ b/fs/ubifs/Kconfig
@@ -4,3 +4,11 @@  config UBIFS_SILENCE_MSG
 	help
 	  Make the verbose messages from UBIFS stop printing. This leaves
 	  warnings and errors enabled.
+
+config UBIFS_SILENCE_DEBUG_DUMP
+	bool "UBIFS silence debug dumps"
+	default y if UBIFS_SILENCE_MSG
+	default n
+	help
+	  Make the debug dumps from UBIFS stop printing.
+	  This decreases size of U-Boot binary.
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 2ff8f1a5f9b1..bede7d01cab0 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -35,6 +35,7 @@ 
 static DEFINE_SPINLOCK(dbg_lock);
 #endif
 
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 static const char *get_key_fmt(int fmt)
 {
 	switch (fmt) {
@@ -230,6 +231,7 @@  static void dump_ch(const struct ubifs_ch *ch)
 	       (unsigned long long)le64_to_cpu(ch->sqnum));
 	pr_err("\tlen            %u\n", le32_to_cpu(ch->len));
 }
+#endif
 
 void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
 {
@@ -303,6 +305,7 @@  void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode)
 
 void ubifs_dump_node(const struct ubifs_info *c, const void *node)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	int i, n;
 	union ubifs_key key;
 	const struct ubifs_ch *ch = node;
@@ -546,10 +549,12 @@  void ubifs_dump_node(const struct ubifs_info *c, const void *node)
 		       (int)ch->node_type);
 	}
 	spin_unlock(&dbg_lock);
+#endif
 }
 
 void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	spin_lock(&dbg_lock);
 	pr_err("Budgeting request: new_ino %d, dirtied_ino %d\n",
 	       req->new_ino, req->dirtied_ino);
@@ -563,10 +568,12 @@  void ubifs_dump_budget_req(const struct ubifs_budget_req *req)
 	pr_err("\tdata_growth %d dd_growth     %d\n",
 	       req->data_growth, req->dd_growth);
 	spin_unlock(&dbg_lock);
+#endif
 }
 
 void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	spin_lock(&dbg_lock);
 	pr_err("(pid %d) Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
 	       current->pid, lst->empty_lebs, lst->idx_lebs);
@@ -575,6 +582,7 @@  void ubifs_dump_lstats(const struct ubifs_lp_stats *lst)
 	pr_err("\ttotal_used %lld, total_dark %lld, total_dead %lld\n",
 	       lst->total_used, lst->total_dark, lst->total_dead);
 	spin_unlock(&dbg_lock);
+#endif
 }
 
 #ifndef __UBOOT__
@@ -653,6 +661,7 @@  void ubifs_dump_budg(struct ubifs_info *c, const struct ubifs_budg_info *bi)
 
 void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	int i, spc, dark = 0, dead = 0;
 	struct rb_node *rb;
 	struct ubifs_bud *bud;
@@ -740,6 +749,7 @@  void ubifs_dump_lprop(const struct ubifs_info *c, const struct ubifs_lprops *lp)
 	if (lp->lnum == c->gc_lnum)
 		pr_cont(", GC LEB");
 	pr_cont(")\n");
+#endif
 }
 
 void ubifs_dump_lprops(struct ubifs_info *c)
@@ -766,6 +776,7 @@  void ubifs_dump_lprops(struct ubifs_info *c)
 
 void ubifs_dump_lpt_info(struct ubifs_info *c)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	int i;
 
 	spin_lock(&dbg_lock);
@@ -800,11 +811,13 @@  void ubifs_dump_lpt_info(struct ubifs_info *c)
 		       i + c->lpt_first, c->ltab[i].free, c->ltab[i].dirty,
 		       c->ltab[i].tgc, c->ltab[i].cmt);
 	spin_unlock(&dbg_lock);
+#endif
 }
 
 void ubifs_dump_sleb(const struct ubifs_info *c,
 		     const struct ubifs_scan_leb *sleb, int offs)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	struct ubifs_scan_node *snod;
 
 	pr_err("(pid %d) start dumping scanned data from LEB %d:%d\n",
@@ -816,10 +829,12 @@  void ubifs_dump_sleb(const struct ubifs_info *c,
 		       sleb->lnum, snod->offs, snod->len);
 		ubifs_dump_node(c, snod->node);
 	}
+#endif
 }
 
 void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	struct ubifs_scan_leb *sleb;
 	struct ubifs_scan_node *snod;
 	void *buf;
@@ -854,11 +869,13 @@  void ubifs_dump_leb(const struct ubifs_info *c, int lnum)
 out:
 	vfree(buf);
 	return;
+#endif
 }
 
 void ubifs_dump_znode(const struct ubifs_info *c,
 		      const struct ubifs_znode *znode)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	int n;
 	const struct ubifs_zbranch *zbr;
 	char key_buf[DBG_KEY_BUF_LEN];
@@ -893,10 +910,12 @@  void ubifs_dump_znode(const struct ubifs_info *c,
 						DBG_KEY_BUF_LEN));
 	}
 	spin_unlock(&dbg_lock);
+#endif
 }
 
 void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	int i;
 
 	pr_err("(pid %d) start dumping heap cat %d (%d elements)\n",
@@ -909,11 +928,13 @@  void ubifs_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
 		       lprops->dirty, lprops->flags);
 	}
 	pr_err("(pid %d) finish dumping heap\n", current->pid);
+#endif
 }
 
 void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
 		      struct ubifs_nnode *parent, int iip)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	int i;
 
 	pr_err("(pid %d) dumping pnode:\n", current->pid);
@@ -927,10 +948,12 @@  void ubifs_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
 		pr_err("\t%d: free %d dirty %d flags %d lnum %d\n",
 		       i, lp->free, lp->dirty, lp->flags, lp->lnum);
 	}
+#endif
 }
 
 void ubifs_dump_tnc(struct ubifs_info *c)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	struct ubifs_znode *znode;
 	int level;
 
@@ -948,14 +971,17 @@  void ubifs_dump_tnc(struct ubifs_info *c)
 		znode = ubifs_tnc_levelorder_next(c->zroot.znode, znode);
 	}
 	pr_err("(pid %d) finish dumping TNC tree\n", current->pid);
+#endif
 }
 
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
 		      void *priv)
 {
 	ubifs_dump_znode(c, znode);
 	return 0;
 }
+#endif
 
 /**
  * ubifs_dump_index - dump the on-flash index.
@@ -966,7 +992,9 @@  static int dump_znode(struct ubifs_info *c, struct ubifs_znode *znode,
  */
 void ubifs_dump_index(struct ubifs_info *c)
 {
+#ifndef CONFIG_UBIFS_SILENCE_DEBUG_DUMP
 	dbg_walk_index(c, NULL, dump_znode, NULL);
+#endif
 }
 
 #ifndef __UBOOT__