From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id AB5C16B0395 for ; Tue, 7 Mar 2017 11:02:27 -0500 (EST) Received: by mail-pf0-f199.google.com with SMTP id o126so9739007pfb.2 for ; Tue, 07 Mar 2017 08:02:27 -0800 (PST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id z13si422203pfj.93.2017.03.07.08.02.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Mar 2017 08:02:21 -0800 (PST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v27FrvQd050455 for ; Tue, 7 Mar 2017 11:02:21 -0500 Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) by mx0a-001b2d01.pphosted.com with ESMTP id 291xwpv0e8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Mar 2017 11:02:21 -0500 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Mar 2017 02:02:18 +1000 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v27G29EP43581472 for ; Wed, 8 Mar 2017 03:02:17 +1100 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v27G1iND030023 for ; Wed, 8 Mar 2017 03:01:44 +1100 Subject: Re: [PATCH] mm: Do not use double negation for testing page flags References: <1488868597-32222-1-git-send-email-minchan@kernel.org> From: Anshuman Khandual Date: Tue, 7 Mar 2017 21:31:18 +0530 MIME-Version: 1.0 In-Reply-To: <1488868597-32222-1-git-send-email-minchan@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Message-Id: <8b5c4679-484e-fe7f-844b-af5fd41b01e0@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Vlastimil Vlastimil Babka , Michal Hocko , "Kirill A . Shutemov" , Johannes Weiner , Chen Gang On 03/07/2017 12:06 PM, Minchan Kim wrote: > With the discussion[1], I found it seems there are every PageFlags > functions return bool at this moment so we don't need double > negation any more. > Although it's not a problem to keep it, it makes future users > confused to use dobule negation for them, too. > > Remove such possibility. A quick search of '!!Page' in the source tree does not show any other place having this double negation. So I guess this is all which need to be fixed. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id C96256B0389 for ; Tue, 7 Mar 2017 12:45:28 -0500 (EST) Received: by mail-wr0-f199.google.com with SMTP id v66so3112881wrc.4 for ; Tue, 07 Mar 2017 09:45:28 -0800 (PST) Received: from gum.cmpxchg.org (gum.cmpxchg.org. [85.214.110.215]) by mx.google.com with ESMTPS id v25si856399wra.330.2017.03.07.09.45.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Mar 2017 09:45:27 -0800 (PST) Date: Tue, 7 Mar 2017 12:39:34 -0500 From: Johannes Weiner Subject: Re: [PATCH] mm: Do not use double negation for testing page flags Message-ID: <20170307173934.GA22291@cmpxchg.org> References: <1488868597-32222-1-git-send-email-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1488868597-32222-1-git-send-email-minchan@kernel.org> Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Vlastimil Vlastimil Babka , Michal Hocko , "Kirill A . Shutemov" , Chen Gang On Tue, Mar 07, 2017 at 03:36:37PM +0900, Minchan Kim wrote: > With the discussion[1], I found it seems there are every PageFlags > functions return bool at this moment so we don't need double > negation any more. > Although it's not a problem to keep it, it makes future users > confused to use dobule negation for them, too. > > Remove such possibility. > > [1] https://marc.info/?l=linux-kernel&m=148881578820434 > > Frankly sepaking, I like every PageFlags return bool instead of int. > It will make it clear. AFAIR, Chen Gang had tried it but don't know > why it was not merged at that time. > > http://lkml.kernel.org/r/1469336184-1904-1-git-send-email-chengang@emindsoft.com.cn > > Cc: Vlastimil Vlastimil Babka > Cc: Michal Hocko > Cc: Kirill A. Shutemov > Cc: Johannes Weiner > Cc: Chen Gang > Signed-off-by: Minchan Kim Acked-by: Johannes Weiner -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 4EDA56B0390 for ; Wed, 8 Mar 2017 00:25:58 -0500 (EST) Received: by mail-pg0-f70.google.com with SMTP id 77so38955614pgc.5 for ; Tue, 07 Mar 2017 21:25:58 -0800 (PST) Received: from lgeamrelo11.lge.com (LGEAMRELO11.lge.com. [156.147.23.51]) by mx.google.com with ESMTP id p1si2138391pld.214.2017.03.07.21.25.56 for ; Tue, 07 Mar 2017 21:25:57 -0800 (PST) Date: Wed, 8 Mar 2017 14:25:55 +0900 From: Minchan Kim Subject: Re: [PATCH] mm: Do not use double negation for testing page flags Message-ID: <20170308052555.GB11206@bbox> References: <1488868597-32222-1-git-send-email-minchan@kernel.org> <8b5c4679-484e-fe7f-844b-af5fd41b01e0@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8b5c4679-484e-fe7f-844b-af5fd41b01e0@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Anshuman Khandual Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Vlastimil Vlastimil Babka , Michal Hocko , "Kirill A . Shutemov" , Johannes Weiner , Chen Gang Hi Anshuman, On Tue, Mar 07, 2017 at 09:31:18PM +0530, Anshuman Khandual wrote: > On 03/07/2017 12:06 PM, Minchan Kim wrote: > > With the discussion[1], I found it seems there are every PageFlags > > functions return bool at this moment so we don't need double > > negation any more. > > Although it's not a problem to keep it, it makes future users > > confused to use dobule negation for them, too. > > > > Remove such possibility. > > A quick search of '!!Page' in the source tree does not show any other > place having this double negation. So I guess this is all which need > to be fixed. Yeb. That's the why my patch includes only khugepagd part but my concern is PageFlags returns int type not boolean so user might be confused easily and tempted to use dobule negation. Other side is they who create new custom PageXXX(e.g., PageMovable) should keep it in mind that they should return 0 or 1 although fucntion prototype's return value is int type. It shouldn't be documented nowhere. Although we can add a little description somewhere in page-flags.h, I believe changing to boolean is more clear/not-error-prone so Chen's work is enough worth, I think. -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 49B7D6B03BD for ; Wed, 8 Mar 2017 02:51:27 -0500 (EST) Received: by mail-wm0-f71.google.com with SMTP id g8so8650323wmg.7 for ; Tue, 07 Mar 2017 23:51:27 -0800 (PST) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id x61si3223145wrb.294.2017.03.07.23.51.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 Mar 2017 23:51:25 -0800 (PST) Subject: Re: [PATCH] mm: Do not use double negation for testing page flags References: <1488868597-32222-1-git-send-email-minchan@kernel.org> <8b5c4679-484e-fe7f-844b-af5fd41b01e0@linux.vnet.ibm.com> <20170308052555.GB11206@bbox> From: Vlastimil Babka Message-ID: <6f9274f7-6d2e-60a6-c36a-78f8f79004aa@suse.cz> Date: Wed, 8 Mar 2017 08:51:23 +0100 MIME-Version: 1.0 In-Reply-To: <20170308052555.GB11206@bbox> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim , Anshuman Khandual Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Michal Hocko , "Kirill A . Shutemov" , Johannes Weiner , Chen Gang On 03/08/2017 06:25 AM, Minchan Kim wrote: > Hi Anshuman, > > On Tue, Mar 07, 2017 at 09:31:18PM +0530, Anshuman Khandual wrote: >> On 03/07/2017 12:06 PM, Minchan Kim wrote: >>> With the discussion[1], I found it seems there are every PageFlags >>> functions return bool at this moment so we don't need double >>> negation any more. >>> Although it's not a problem to keep it, it makes future users >>> confused to use dobule negation for them, too. >>> >>> Remove such possibility. >> >> A quick search of '!!Page' in the source tree does not show any other >> place having this double negation. So I guess this is all which need >> to be fixed. > > Yeb. That's the why my patch includes only khugepagd part but my > concern is PageFlags returns int type not boolean so user might > be confused easily and tempted to use dobule negation. > > Other side is they who create new custom PageXXX(e.g., PageMovable) > should keep it in mind that they should return 0 or 1 although > fucntion prototype's return value is int type. > It shouldn't be > documented nowhere. Was this double negation intentional? :P > Although we can add a little description > somewhere in page-flags.h, I believe changing to boolean is more > clear/not-error-prone so Chen's work is enough worth, I think. Agree, unless some arches benefit from the int by performance for some reason (no idea if it's possible). Anyway, to your original patch: Acked-by: Vlastimil Babka -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f198.google.com (mail-wr0-f198.google.com [209.85.128.198]) by kanga.kvack.org (Postfix) with ESMTP id A4E7E831D3 for ; Wed, 8 Mar 2017 04:18:07 -0500 (EST) Received: by mail-wr0-f198.google.com with SMTP id v66so9069363wrc.4 for ; Wed, 08 Mar 2017 01:18:07 -0800 (PST) Received: from mx2.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id i25si3508144wrc.245.2017.03.08.01.18.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Mar 2017 01:18:06 -0800 (PST) Date: Wed, 8 Mar 2017 10:18:03 +0100 From: Michal Hocko Subject: Re: [PATCH] mm: Do not use double negation for testing page flags Message-ID: <20170308091802.GA11028@dhcp22.suse.cz> References: <1488868597-32222-1-git-send-email-minchan@kernel.org> <8b5c4679-484e-fe7f-844b-af5fd41b01e0@linux.vnet.ibm.com> <20170308052555.GB11206@bbox> <6f9274f7-6d2e-60a6-c36a-78f8f79004aa@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f9274f7-6d2e-60a6-c36a-78f8f79004aa@suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Minchan Kim , Anshuman Khandual , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, "Kirill A . Shutemov" , Johannes Weiner , Chen Gang On Wed 08-03-17 08:51:23, Vlastimil Babka wrote: > On 03/08/2017 06:25 AM, Minchan Kim wrote: [...] > > Although we can add a little description > > somewhere in page-flags.h, I believe changing to boolean is more > > clear/not-error-prone so Chen's work is enough worth, I think. > > Agree, unless some arches benefit from the int by performance > for some reason (no idea if it's possible). I have a vague recollection somebody tried to change this to bool and the resulting code was larger on some architecture. Do not remember any details though Btw. feel free to add Acked-by: Michal Hocko -- Michal Hocko SUSE Labs -- 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id BA9DD831FE for ; Thu, 9 Mar 2017 01:42:27 -0500 (EST) Received: by mail-pg0-f69.google.com with SMTP id 77so93432422pgc.5 for ; Wed, 08 Mar 2017 22:42:27 -0800 (PST) Received: from lgeamrelo12.lge.com (LGEAMRELO12.lge.com. [156.147.23.52]) by mx.google.com with ESMTP id w7si5501274pgc.395.2017.03.08.22.42.26 for ; Wed, 08 Mar 2017 22:42:27 -0800 (PST) Date: Thu, 9 Mar 2017 15:42:24 +0900 From: Minchan Kim Subject: Re: [PATCH] mm: Do not use double negation for testing page flags Message-ID: <20170309064224.GD854@bbox> References: <1488868597-32222-1-git-send-email-minchan@kernel.org> <8b5c4679-484e-fe7f-844b-af5fd41b01e0@linux.vnet.ibm.com> <20170308052555.GB11206@bbox> <6f9274f7-6d2e-60a6-c36a-78f8f79004aa@suse.cz> MIME-Version: 1.0 In-Reply-To: <6f9274f7-6d2e-60a6-c36a-78f8f79004aa@suse.cz> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: Anshuman Khandual , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Michal Hocko , "Kirill A . Shutemov" , Johannes Weiner , Chen Gang Hi Vlastimil, On Wed, Mar 08, 2017 at 08:51:23AM +0100, Vlastimil Babka wrote: > On 03/08/2017 06:25 AM, Minchan Kim wrote: > > Hi Anshuman, > > > > On Tue, Mar 07, 2017 at 09:31:18PM +0530, Anshuman Khandual wrote: > >> On 03/07/2017 12:06 PM, Minchan Kim wrote: > >>> With the discussion[1], I found it seems there are every PageFlags > >>> functions return bool at this moment so we don't need double > >>> negation any more. > >>> Although it's not a problem to keep it, it makes future users > >>> confused to use dobule negation for them, too. > >>> > >>> Remove such possibility. > >> > >> A quick search of '!!Page' in the source tree does not show any other > >> place having this double negation. So I guess this is all which need > >> to be fixed. > > > > Yeb. That's the why my patch includes only khugepagd part but my > > concern is PageFlags returns int type not boolean so user might > > be confused easily and tempted to use dobule negation. > > > > Other side is they who create new custom PageXXX(e.g., PageMovable) > > should keep it in mind that they should return 0 or 1 although > > fucntion prototype's return value is int type. > > > It shouldn't be > > documented nowhere. > > Was this double negation intentional? :P Nice catch! It seems you have a crystal ball. ;-) > > > Although we can add a little description > > somewhere in page-flags.h, I believe changing to boolean is more > > clear/not-error-prone so Chen's work is enough worth, I think. > > Agree, unless some arches benefit from the int by performance > for some reason (no idea if it's possible). > > Anyway, to your original patch: > > Acked-by: Vlastimil Babka 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: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Minchan Kim Subject: [PATCH] mm: Do not use double negation for testing page flags Date: Tue, 7 Mar 2017 15:36:37 +0900 Message-ID: <1488868597-32222-1-git-send-email-minchan@kernel.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Sender: linux-kernel-owner@vger.kernel.org To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Minchan Kim , Vlastimil Vlastimil Babka , Michal Hocko , "Kirill A . Shutemov" , Johannes Weiner , Chen Gang List-Id: linux-mm.kvack.org With the discussion[1], I found it seems there are every PageFlags functions return bool at this moment so we don't need double negation any more. Although it's not a problem to keep it, it makes future users confused to use dobule negation for them, too. Remove such possibility. [1] https://marc.info/?l=linux-kernel&m=148881578820434 Frankly sepaking, I like every PageFlags return bool instead of int. It will make it clear. AFAIR, Chen Gang had tried it but don't know why it was not merged at that time. http://lkml.kernel.org/r/1469336184-1904-1-git-send-email-chengang@emindsoft.com.cn Cc: Vlastimil Vlastimil Babka Cc: Michal Hocko Cc: Kirill A. Shutemov Cc: Johannes Weiner Cc: Chen Gang Signed-off-by: Minchan Kim --- mm/khugepaged.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 88e4b17..7cb9c88 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -548,7 +548,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, * The page must only be referenced by the scanned process * and page swap cache. */ - if (page_count(page) != 1 + !!PageSwapCache(page)) { + if (page_count(page) != 1 + PageSwapCache(page)) { unlock_page(page); result = SCAN_PAGE_COUNT; goto out; @@ -1181,7 +1181,7 @@ static int khugepaged_scan_pmd(struct mm_struct *mm, * The page must only be referenced by the scanned process * and page swap cache. */ - if (page_count(page) != 1 + !!PageSwapCache(page)) { + if (page_count(page) != 1 + PageSwapCache(page)) { result = SCAN_PAGE_COUNT; goto out_unmap; } -- 2.7.4