linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Lu <aaron.lu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm <linux-mm@kvack.org>,
	lkml <linux-kernel@vger.kernel.org>,
	"Chen, Tim C" <tim.c.chen@intel.com>,
	Huang Ying <ying.huang@intel.com>,
	"Kleen, Andi" <andi.kleen@intel.com>,
	Michal Hocko <mhocko@suse.com>, Minchan Kim <minchan@kernel.org>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH v2] swap: choose swap device according to numa node
Date: Fri, 18 Aug 2017 08:43:11 +0800	[thread overview]
Message-ID: <20170818004311.GB1996@intel.com> (raw)
In-Reply-To: <20170817154408.66c37d2d84eccdb102b9e04c@linux-foundation.org>

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.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2017-08-18  0:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-14  5:31 [PATCH] " Aaron Lu
2017-08-14 23:33 ` Andrew Morton
2017-08-15  5:49   ` Aaron Lu
2017-08-15 22:09     ` Andrew Morton
2017-08-16  2:44       ` [PATCH v2] " Aaron Lu
2017-08-17 22:44         ` Andrew Morton
2017-08-18  0:43           ` Aaron Lu [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=20170818004311.GB1996@intel.com \
    --to=aaron.lu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi.kleen@intel.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=tim.c.chen@intel.com \
    --cc=ying.huang@intel.com \
    /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