mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: tanze <tanze@kylinos.cn>, <richard@nod.at>,
	<hengzhihao1@huawei.com>, <linux-mtd@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ubifs: using vmalloc_array() to handle the code
Date: Wed, 22 Oct 2025 16:14:13 +0800	[thread overview]
Message-ID: <e345c2fa-3151-d8b6-6cd2-b0afd5e13d86@huawei.com> (raw)
In-Reply-To: <20251022080200.526003-1-tanze@kylinos.cn>

在 2025/10/22 16:02, tanze 写道:
> Change array_size() to vmalloc_array(), Due to vmalloc_array()
> is optimized better,uses fewer instructions, and handles
> overflow more concisely
> 
> Signed-off-by: tanze <tanze@kylinos.cn>
> ---
>   fs/ubifs/lpt.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
> index 441d0beca4cf..dde0aa3287f4 100644
> --- a/fs/ubifs/lpt.c
> +++ b/fs/ubifs/lpt.c
> @@ -628,8 +628,8 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
>   	pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL);
>   	nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
>   	buf = vmalloc(c->leb_size);
> -	ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
> -				  c->lpt_lebs));
> +	ltab = vmalloc_array(c->lpt_lebs,
> +			     sizeof(struct ubifs_lpt_lprops));
>   	if (!pnode || !nnode || !buf || !ltab || !lsave) {
>   		err = -ENOMEM;
>   		goto out;
> @@ -1777,8 +1777,8 @@ static int lpt_init_rd(struct ubifs_info *c)
>   {
>   	int err, i;
>   
> -	c->ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
> -				     c->lpt_lebs));
> +	c->ltab = vmalloc_array(c->lpt_lebs,
> +				sizeof(struct ubifs_lpt_lprops));
>   	if (!c->ltab)
>   		return -ENOMEM;
>   
> @@ -1846,8 +1846,8 @@ static int lpt_init_wr(struct ubifs_info *c)
>   {
>   	int err, i;
>   
> -	c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
> -					 c->lpt_lebs));
> +	c->ltab_cmt = vmalloc_array(c->lpt_lebs,
> +				    sizeof(struct ubifs_lpt_lprops));
>   	if (!c->ltab_cmt)
>   		return -ENOMEM;
>   
> 


      reply	other threads:[~2025-10-22  8:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22  8:02 tanze
2025-10-22  8:14 ` Zhihao Cheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e345c2fa-3151-d8b6-6cd2-b0afd5e13d86@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=hengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=tanze@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®