linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Qian Cai <cai@lca.pw>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: mgorman@techsingularity.net, vbabka@suse.cz, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RESEND#2 PATCH] mm/compaction: fix an undefined behaviour
Date: Wed, 20 Mar 2019 18:12:40 -0400	[thread overview]
Message-ID: <a82bdba4-530a-95fd-8a05-5fd2fd67e4b4@lca.pw> (raw)
In-Reply-To: <20190320145826.9c647fe53bd999bbd2ee188d@linux-foundation.org>



On 3/20/19 5:58 PM, Andrew Morton wrote:
>> ---
>>  mm/compaction.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/compaction.c b/mm/compaction.c
>> index e1a08fc92353..0d1156578114 100644
>> --- a/mm/compaction.c
>> +++ b/mm/compaction.c
>> @@ -1157,7 +1157,9 @@ static bool suitable_migration_target(struct compact_control *cc,
>>  static inline unsigned int
>>  freelist_scan_limit(struct compact_control *cc)
>>  {
>> -	return (COMPACT_CLUSTER_MAX >> cc->fast_search_fail) + 1;
>> +	return (COMPACT_CLUSTER_MAX >>
>> +		min((unsigned short)(BITS_PER_LONG - 1), cc->fast_search_fail))
>> +		+ 1;
>>  }
> 
> That's rather an eyesore.  How about
> 
> static inline unsigned int
> freelist_scan_limit(struct compact_control *cc)
> {
> 	unsigned short shift = BITS_PER_LONG - 1;
> 
> 	return (COMPACT_CLUSTER_MAX >> min(shift, cc->fast_search_fail)) + 1;
> }

Agree. It looks better.


      reply	other threads:[~2019-03-20 22:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 20:33 Qian Cai
2019-03-20 21:58 ` Andrew Morton
2019-03-20 22:12   ` Qian Cai [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=a82bdba4-530a-95fd-8a05-5fd2fd67e4b4@lca.pw \
    --to=cai@lca.pw \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=vbabka@suse.cz \
    /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