Skip to content

Commit 0695aef

Browse files
qianfengrongrichardweinberger
authored andcommitted
ubifs: vmalloc(array_size()) -> vmalloc_array()
Remove array_size() calls and replace vmalloc() with vmalloc_array() in ubifs_create_dflt_lpt()/lpt_init_rd()/lpt_init_wr(). vmalloc_array() is optimized better, resulting in less instructions being used [1]. [1]: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Qianfeng Rong <[email protected]> Reviewed-by: Zhihao Cheng <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent d133e30 commit 0695aef

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

fs/ubifs/lpt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,8 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
628628
pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL);
629629
nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
630630
buf = vmalloc(c->leb_size);
631-
ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
632-
c->lpt_lebs));
631+
ltab = vmalloc_array(c->lpt_lebs,
632+
sizeof(struct ubifs_lpt_lprops));
633633
if (!pnode || !nnode || !buf || !ltab || !lsave) {
634634
err = -ENOMEM;
635635
goto out;
@@ -1777,8 +1777,8 @@ static int lpt_init_rd(struct ubifs_info *c)
17771777
{
17781778
int err, i;
17791779

1780-
c->ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
1781-
c->lpt_lebs));
1780+
c->ltab = vmalloc_array(c->lpt_lebs,
1781+
sizeof(struct ubifs_lpt_lprops));
17821782
if (!c->ltab)
17831783
return -ENOMEM;
17841784

@@ -1846,8 +1846,8 @@ static int lpt_init_wr(struct ubifs_info *c)
18461846
{
18471847
int err, i;
18481848

1849-
c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
1850-
c->lpt_lebs));
1849+
c->ltab_cmt = vmalloc_array(c->lpt_lebs,
1850+
sizeof(struct ubifs_lpt_lprops));
18511851
if (!c->ltab_cmt)
18521852
return -ENOMEM;
18531853

0 commit comments

Comments
 (0)