lkml.org 
[lkml]   [2017]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] swap: choose swap device according to numa node
On Thu, Aug 17, 2017 at 03:44:08PM -0700, Andrew Morton wrote:
> On Wed, 16 Aug 2017 10:44:40 +0800 Aaron Lu <aaron.lu@intel.com> wrote:
> > ...
> >
> > +static int __init swapfile_init(void)
> > +{
> > + int nid;
> > +
> > + swap_avail_heads = kmalloc(nr_node_ids * sizeof(struct plist_head), GFP_KERNEL);
>
> I suppose we should use kmalloc_array(), as someone wrote it for us.
>
> --- a/mm/swapfile.c~swap-choose-swap-device-according-to-numa-node-v2-fix
> +++ a/mm/swapfile.c
> @@ -3700,7 +3700,8 @@ static int __init swapfile_init(void)
> {
> int nid;
>
> - swap_avail_heads = kmalloc(nr_node_ids * sizeof(struct plist_head), GFP_KERNEL);
> + swap_avail_heads = kmalloc_array(nr_node_ids, sizeof(struct plist_head),
> + GFP_KERNEL);
> if (!swap_avail_heads) {
> pr_emerg("Not enough memory for swap heads, swap is disabled\n");
> return -ENOMEM;
>
> > + if (!swap_avail_heads) {
> > + pr_emerg("Not enough memory for swap heads, swap is disabled\n");
>
> checkpatch tells us that the "Not enough memory" is a bit redundant, as
> the memory allocator would have already warned. So it's sufficient to
> additionally say only "swap is disabled" here. But it's hardly worth
> changing.

Thanks Andrew for taking care of this.

\
 
 \ /
  Last update: 2017-08-18 02:44    [W:0.041 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site