* [PATCH] zsmalloc: use U suffix for negative literals being shifted @ 2017-12-24 2:33 Nick Desaulniers 2017-12-24 3:24 ` Matthew Wilcox 2018-01-07 15:04 ` Minchan Kim 0 siblings, 2 replies; 10+ messages in thread From: Nick Desaulniers @ 2017-12-24 2:33 UTC (permalink / raw) Cc: Nick Desaulniers, Minchan Kim, Nitin Gupta, Sergey Senozhatsky, linux-mm, linux-kernel Fixes warnings about shifting unsigned literals being undefined behavior. Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com> --- mm/zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 685049a..5d31458 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1056,7 +1056,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) * Reset OBJ_TAG_BITS bit to last link to tell * whether it's allocated object or not. */ - link->next = -1 << OBJ_TAG_BITS; + link->next = -1U << OBJ_TAG_BITS; } kunmap_atomic(vaddr); page = next_page; -- 2.7.4 -- 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> ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] zsmalloc: use U suffix for negative literals being shifted 2017-12-24 2:33 [PATCH] zsmalloc: use U suffix for negative literals being shifted Nick Desaulniers @ 2017-12-24 3:24 ` Matthew Wilcox 2017-12-24 3:28 ` Nick Desaulniers 2018-01-07 15:04 ` Minchan Kim 1 sibling, 1 reply; 10+ messages in thread From: Matthew Wilcox @ 2017-12-24 3:24 UTC (permalink / raw) To: Nick Desaulniers Cc: Minchan Kim, Nitin Gupta, Sergey Senozhatsky, linux-mm, linux-kernel On Sat, Dec 23, 2017 at 09:33:40PM -0500, Nick Desaulniers wrote: > Fixes warnings about shifting unsigned literals being undefined > behavior. Do you mean signed literals? > */ > - link->next = -1 << OBJ_TAG_BITS; > + link->next = -1U << OBJ_TAG_BITS; > } I don't understand what -1U means. Seems like a contradiction in terms, a negative unsigned number. Is this supposed to be ~0U? -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] zsmalloc: use U suffix for negative literals being shifted 2017-12-24 3:24 ` Matthew Wilcox @ 2017-12-24 3:28 ` Nick Desaulniers 2018-01-06 20:40 ` Nick Desaulniers 0 siblings, 1 reply; 10+ messages in thread From: Nick Desaulniers @ 2017-12-24 3:28 UTC (permalink / raw) To: Matthew Wilcox Cc: Minchan Kim, Nitin Gupta, Sergey Senozhatsky, linux-mm, Linux Kernel Mailing List On Sat, Dec 23, 2017 at 10:24 PM, Matthew Wilcox <willy@infradead.org> wrote: > On Sat, Dec 23, 2017 at 09:33:40PM -0500, Nick Desaulniers wrote: >> Fixes warnings about shifting unsigned literals being undefined >> behavior. > > Do you mean signed literals? A sorry, s/unsigned/negative signed/g. The warning is: mm/zsmalloc.c:1059:20: warning: shifting a negative signed value is undefined [-Wshift-negative-value] link->next = -1 << OBJ_TAG_BITS; ~~ ^ > >> */ >> - link->next = -1 << OBJ_TAG_BITS; >> + link->next = -1U << OBJ_TAG_BITS; >> } > > I don't understand what -1U means. Seems like a contradiction in terms, > a negative unsigned number. Is this supposed to be ~0U? $ ag \\-1U[^L] The code base is full of that literal. I think of it as: (unsigned) -1 -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] zsmalloc: use U suffix for negative literals being shifted 2017-12-24 3:28 ` Nick Desaulniers @ 2018-01-06 20:40 ` Nick Desaulniers 0 siblings, 0 replies; 10+ messages in thread From: Nick Desaulniers @ 2018-01-06 20:40 UTC (permalink / raw) To: Matthew Wilcox, Minchan Kim, Nitin Gupta Cc: Sergey Senozhatsky, linux-mm, Linux Kernel Mailing List Hello, What are the next steps for this patch? Note: the MAINTAINERS file does not contain a T: (tree) entry for ZSMALLOC, so I can't check to see if this has already been merged or not. Unless you work out of the mm tree? -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] zsmalloc: use U suffix for negative literals being shifted 2017-12-24 2:33 [PATCH] zsmalloc: use U suffix for negative literals being shifted Nick Desaulniers 2017-12-24 3:24 ` Matthew Wilcox @ 2018-01-07 15:04 ` Minchan Kim 2018-01-07 23:02 ` Andy Shevchenko 1 sibling, 1 reply; 10+ messages in thread From: Minchan Kim @ 2018-01-07 15:04 UTC (permalink / raw) To: Nick Desaulniers; +Cc: Nitin Gupta, Sergey Senozhatsky, linux-mm, linux-kernel Hello, Sorry for the delay. I have missed this until now. ;-( On Sun, Dec 24, 2017 at 11:33 AM, Nick Desaulniers <nick.desaulniers@gmail.com> wrote: > Fixes warnings about shifting unsigned literals being undefined > behavior. > > Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com> > --- > mm/zsmalloc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index 685049a..5d31458 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -1056,7 +1056,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) > * Reset OBJ_TAG_BITS bit to last link to tell > * whether it's allocated object or not. > */ > - link->next = -1 << OBJ_TAG_BITS; > + link->next = -1U << OBJ_TAG_BITS; -1UL? Please, resend it with including Andrew Morton <akpm@linux-foundation.org> who merges zsmalloc patch into his tree. Thanks. -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] zsmalloc: use U suffix for negative literals being shifted 2018-01-07 15:04 ` Minchan Kim @ 2018-01-07 23:02 ` Andy Shevchenko 2018-01-09 4:35 ` Nick Desaulniers 0 siblings, 1 reply; 10+ messages in thread From: Andy Shevchenko @ 2018-01-07 23:02 UTC (permalink / raw) To: Minchan Kim Cc: Nick Desaulniers, Nitin Gupta, Sergey Senozhatsky, linux-mm, linux-kernel On Sun, Jan 7, 2018 at 5:04 PM, Minchan Kim <minchan@kernel.org> wrote: >> - link->next = -1 << OBJ_TAG_BITS; >> + link->next = -1U << OBJ_TAG_BITS; > > -1UL? Oh, boy, shouldn't be rather GENMASK() / GENMASK_ULL() in a way how it's done, for example, here: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git/commit/?h=for-next&id=d2b3c353595a855794f8b9df5b5bdbe8deb0c413 -- With Best Regards, Andy Shevchenko -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] zsmalloc: use U suffix for negative literals being shifted 2018-01-07 23:02 ` Andy Shevchenko @ 2018-01-09 4:35 ` Nick Desaulniers 2018-01-10 5:53 ` Minchan Kim 0 siblings, 1 reply; 10+ messages in thread From: Nick Desaulniers @ 2018-01-09 4:35 UTC (permalink / raw) To: Andy Shevchenko, Minchan Kim Cc: Nitin Gupta, Sergey Senozhatsky, linux-mm, linux-kernel On Sun, Jan 7, 2018 at 7:04 AM, Minchan Kim <minchan@kernel.org> wrote: > Sorry for the delay. I have missed this until now. ;-( No worries, figured patches would need a post holiday bump for review. > > On Sun, Dec 24, 2017 at 11:33 AM, Nick Desaulniers > <nick.desaulniers@gmail.com> wrote: >> - link->next = -1 << OBJ_TAG_BITS; >> + link->next = -1U << OBJ_TAG_BITS; > > -1UL? Oops, good catch. > Please, resend it with including Andrew Morton > <akpm@linux-foundation.org> who merges zsmalloc patch into his tree. Will do. On Sun, Jan 7, 2018 at 3:02 PM, Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > Oh, boy, shouldn't be rather GENMASK() / GENMASK_ULL() in a way how Thanks for the suggestion. `GENMASK(BITS_PER_LONG - 1, OBJ_TAG_BITS);` is equivalent. Whether that is more readable, I'll wait for Minchan to decide. If that's preferred, I'll make sure to credit you with the Suggested-By tag in the commit message. -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] zsmalloc: use U suffix for negative literals being shifted 2018-01-09 4:35 ` Nick Desaulniers @ 2018-01-10 5:53 ` Minchan Kim 2018-01-11 3:41 ` [PATCH v2] " Nick Desaulniers 0 siblings, 1 reply; 10+ messages in thread From: Minchan Kim @ 2018-01-10 5:53 UTC (permalink / raw) To: Nick Desaulniers Cc: Andy Shevchenko, Nitin Gupta, Sergey Senozhatsky, linux-mm, linux-kernel Hi Nick, On Mon, Jan 08, 2018 at 08:35:19PM -0800, Nick Desaulniers wrote: > On Sun, Jan 7, 2018 at 7:04 AM, Minchan Kim <minchan@kernel.org> wrote: > > Sorry for the delay. I have missed this until now. ;-( > > No worries, figured patches would need a post holiday bump for review. > > > > > On Sun, Dec 24, 2017 at 11:33 AM, Nick Desaulniers > > <nick.desaulniers@gmail.com> wrote: > >> - link->next = -1 << OBJ_TAG_BITS; > >> + link->next = -1U << OBJ_TAG_BITS; > > > > -1UL? > > Oops, good catch. > > > Please, resend it with including Andrew Morton > > <akpm@linux-foundation.org> who merges zsmalloc patch into his tree. > > Will do. > > On Sun, Jan 7, 2018 at 3:02 PM, Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: > > Oh, boy, shouldn't be rather GENMASK() / GENMASK_ULL() in a way how > > Thanks for the suggestion. `GENMASK(BITS_PER_LONG - 1, OBJ_TAG_BITS);` > is equivalent. Whether that is more readable, I'll wait for Minchan > to decide. If that's preferred, I'll make sure to credit you with the > Suggested-By tag in the commit message. I don't see any benefit with GENMASK in our usecase. If it's not a good justfication, I'd like to use just -1UL which would be more readable without effort to understand new API. Thanks. -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] zsmalloc: use U suffix for negative literals being shifted 2018-01-10 5:53 ` Minchan Kim @ 2018-01-11 3:41 ` Nick Desaulniers 2018-01-11 7:06 ` Sergey Senozhatsky 0 siblings, 1 reply; 10+ messages in thread From: Nick Desaulniers @ 2018-01-11 3:41 UTC (permalink / raw) To: akpm Cc: Andy Shevchenko, Matthew Wilcox, Nick Desaulniers, Minchan Kim, Nitin Gupta, Sergey Senozhatsky, linux-mm, linux-kernel Fixes warnings about shifting unsigned literals being undefined behavior. Suggested-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com> --- Changes since v1: * Use L suffix in addition to U, as suggested (link->next is unsigned long). mm/zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 683c065..b9040bd 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1057,7 +1057,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) * Reset OBJ_TAG_BITS bit to last link to tell * whether it's allocated object or not. */ - link->next = -1 << OBJ_TAG_BITS; + link->next = -1UL << OBJ_TAG_BITS; } kunmap_atomic(vaddr); page = next_page; -- 2.7.4 -- 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> ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] zsmalloc: use U suffix for negative literals being shifted 2018-01-11 3:41 ` [PATCH v2] " Nick Desaulniers @ 2018-01-11 7:06 ` Sergey Senozhatsky 0 siblings, 0 replies; 10+ messages in thread From: Sergey Senozhatsky @ 2018-01-11 7:06 UTC (permalink / raw) To: Nick Desaulniers Cc: akpm, Andy Shevchenko, Matthew Wilcox, Minchan Kim, Nitin Gupta, Sergey Senozhatsky, linux-mm, linux-kernel On (01/10/18 19:41), Nick Desaulniers wrote: > Fixes warnings about shifting unsigned literals being undefined > behavior. > > Suggested-by: Minchan Kim <minchan@kernel.org> > Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com> looks good to me. Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> -ss -- 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> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-01-11 7:06 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-12-24 2:33 [PATCH] zsmalloc: use U suffix for negative literals being shifted Nick Desaulniers 2017-12-24 3:24 ` Matthew Wilcox 2017-12-24 3:28 ` Nick Desaulniers 2018-01-06 20:40 ` Nick Desaulniers 2018-01-07 15:04 ` Minchan Kim 2018-01-07 23:02 ` Andy Shevchenko 2018-01-09 4:35 ` Nick Desaulniers 2018-01-10 5:53 ` Minchan Kim 2018-01-11 3:41 ` [PATCH v2] " Nick Desaulniers 2018-01-11 7:06 ` Sergey Senozhatsky
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).