Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1669081 > unrolled thread
| Started by | Hao Lee <haolee.swjtu@gmail.com> |
|---|---|
| First post | 2017-06-19 16:00 +0200 |
| Last post | 2017-06-19 22:30 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] mm: remove a redundant condition in the for loop Hao Lee <haolee.swjtu@gmail.com> - 2017-06-19 16:00 +0200
Re: [PATCH] mm: remove a redundant condition in the for loop Vlastimil Babka <vbabka@suse.cz> - 2017-06-19 16:20 +0200
Re: [PATCH] mm: remove a redundant condition in the for loop Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2017-06-19 21:10 +0200
Re: [PATCH] mm: remove a redundant condition in the for loop Vlastimil Babka <vbabka@suse.cz> - 2017-06-19 22:30 +0200
| From | Hao Lee <haolee.swjtu@gmail.com> |
|---|---|
| Date | 2017-06-19 16:00 +0200 |
| Subject | [PATCH] mm: remove a redundant condition in the for loop |
| Message-ID | <tU5nI-3mQ-1@gated-at.bofh.it> |
The variable current_order decreases from MAX_ORDER-1 to order, so the
condition current_order <= MAX_ORDER-1 is always true.
Signed-off-by: Hao Lee <haolee.swjtu@gmail.com>
---
mm/page_alloc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2302f25..9120c2b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2215,9 +2215,8 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype)
bool can_steal;
/* Find the largest possible block of pages in the other list */
- for (current_order = MAX_ORDER-1;
- current_order >= order && current_order <= MAX_ORDER-1;
- --current_order) {
+ for (current_order = MAX_ORDER-1; current_order >= order;
+ --current_order) {
area = &(zone->free_area[current_order]);
fallback_mt = find_suitable_fallback(area, current_order,
start_migratetype, false, &can_steal);
--
2.9.3
[toc] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-06-19 16:20 +0200 |
| Message-ID | <tU5H3-3IR-9@gated-at.bofh.it> |
| In reply to | #1669081 |
On 06/19/2017 03:54 PM, Hao Lee wrote:
> The variable current_order decreases from MAX_ORDER-1 to order, so the
> condition current_order <= MAX_ORDER-1 is always true.
>
> Signed-off-by: Hao Lee <haolee.swjtu@gmail.com>
Sounds right.
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/page_alloc.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 2302f25..9120c2b 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2215,9 +2215,8 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype)
> bool can_steal;
>
> /* Find the largest possible block of pages in the other list */
> - for (current_order = MAX_ORDER-1;
> - current_order >= order && current_order <= MAX_ORDER-1;
> - --current_order) {
> + for (current_order = MAX_ORDER-1; current_order >= order;
> + --current_order) {
> area = &(zone->free_area[current_order]);
> fallback_mt = find_suitable_fallback(area, current_order,
> start_migratetype, false, &can_steal);
>
[toc] | [prev] | [next] | [standalone]
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2017-06-19 21:10 +0200 |
| Message-ID | <tUadH-6Iy-3@gated-at.bofh.it> |
| In reply to | #1669100 |
On Mon, Jun 19 2017, Vlastimil Babka <vbabka@suse.cz> wrote:
> On 06/19/2017 03:54 PM, Hao Lee wrote:
>> The variable current_order decreases from MAX_ORDER-1 to order, so the
>> condition current_order <= MAX_ORDER-1 is always true.
>>
>> Signed-off-by: Hao Lee <haolee.swjtu@gmail.com>
>
> Sounds right.
>
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
current_order and order are both unsigned, and if order==0,
current_order >= order is always true, and we may decrement
current_order past 0 making it UINT_MAX... A comment would be in order,
though.
>> ---
>> mm/page_alloc.c | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 2302f25..9120c2b 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -2215,9 +2215,8 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype)
>> bool can_steal;
>>
>> /* Find the largest possible block of pages in the other list */
>> - for (current_order = MAX_ORDER-1;
>> - current_order >= order && current_order <= MAX_ORDER-1;
>> - --current_order) {
>> + for (current_order = MAX_ORDER-1; current_order >= order;
>> + --current_order) {
>> area = &(zone->free_area[current_order]);
>> fallback_mt = find_suitable_fallback(area, current_order,
>> start_migratetype, false, &can_steal);
>>
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2017-06-19 22:30 +0200 |
| Message-ID | <tUbt7-7sP-5@gated-at.bofh.it> |
| In reply to | #1669713 |
On 06/19/2017 09:05 PM, Rasmus Villemoes wrote: > On Mon, Jun 19 2017, Vlastimil Babka <vbabka@suse.cz> wrote: > >> On 06/19/2017 03:54 PM, Hao Lee wrote: >>> The variable current_order decreases from MAX_ORDER-1 to order, so the >>> condition current_order <= MAX_ORDER-1 is always true. >>> >>> Signed-off-by: Hao Lee <haolee.swjtu@gmail.com> >> >> Sounds right. >> >> Acked-by: Vlastimil Babka <vbabka@suse.cz> > > current_order and order are both unsigned, and if order==0, > current_order >= order is always true, and we may decrement > current_order past 0 making it UINT_MAX... A comment would be in order, > though. Doh, right. Thanks.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web