From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57231C47254 for ; Fri, 1 May 2020 01:09:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 308C0207DD for ; Fri, 1 May 2020 01:09:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EtQaTk0B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728037AbgEABJ0 (ORCPT ); Thu, 30 Apr 2020 21:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727114AbgEABJZ (ORCPT ); Thu, 30 Apr 2020 21:09:25 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CA29C035494 for ; Thu, 30 Apr 2020 18:09:25 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id e18so402250oot.9 for ; Thu, 30 Apr 2020 18:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=iXrA9vjDFeyBPogW8X3baa2NAT1RG1h/25KrkcOYPyk=; b=EtQaTk0BIrN9hgAUH4jSlTrl+Q207os/So9AiKENej0LuanW8nWejAFjXnLoZlmeR4 +ti2sYQdpgMPGJECSbnhUmrLXyLoZY6Kug+Vm8v5u1KYOm1/Kof/C8kPVXJDo6GYJVf4 /Q0lpeQZtlf2xXJWWy/sLQ3Xob7UIbAf89bbCTboOcJ6FeSnst/Er7gUIummoUP9f9wX q973lmYcW9qE/wrQVMDaIkcwYZVY15iim0spYQ5SosKYH51UVqU+4baaNY/+xgBjJ5D+ 9xQTGq50SIxOcD8i9g20HwegFCYPdStZGHBi9DYnzp1jfK+2yDry22p+gi7cjRubBQSP u0nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=iXrA9vjDFeyBPogW8X3baa2NAT1RG1h/25KrkcOYPyk=; b=QJF0fI4brYEFiF+tFooY3uTidf5UEv0sF5A5GDO1p54Ai9Jkij90bZ1K3VJCKRx718 4zLPgGNkkpDESP7couNzdXf0o4TVHDdtBC0WMFlqzhudJSEkOqJbYYpiwXZhnhGHOs1V 0S7OPb6LGpV8TOyk9pSaHEjId/Iu796eZqeBeIcl+1IHqqxceEtZYVBgcOLaq4LEZZB0 Cb5UJt57Sby4VTrmdodC5wItNq74jhOGKLkSo33UBgXG8KFtBabkDYaOhByodtKO6fn2 bb+V+aLthiNPPVDvsd2/ZgWSWnPEjfK6UTrR8STtPHyh1/zk14mEPcej+xca5RT2zqhq iKjg== X-Gm-Message-State: AGi0PuZP1ebcn19MDZ2piUCFr7jJXQRPSvAqeG+1NvybGjbTsccAuQQY vBJhGY1V7ODIwRMlNY10ZBcQpA== X-Google-Smtp-Source: APiQypJ+scBXw7K9Y+l1S2jlTS7e2TRgQUfk+9D2W+8cSGXvUZp1msNhnPw4lHxV9WnTP0XblZiwag== X-Received: by 2002:a4a:8253:: with SMTP id t19mr1736955oog.69.1588295364238; Thu, 30 Apr 2020 18:09:24 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id p17sm36208oot.17.2020.04.30.18.09.22 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Thu, 30 Apr 2020 18:09:22 -0700 (PDT) Date: Thu, 30 Apr 2020 18:09:03 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yang Shi cc: "Kirill A. Shutemov" , kirill.shutemov@linux.intel.com, hughd@google.com, aarcange@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [linux-next PATCH 1/2] mm: khugepaged: add exceed_max_ptes_* helpers In-Reply-To: Message-ID: References: <1588200982-69492-1-git-send-email-yang.shi@linux.alibaba.com> <20200430215932.5w5dck3rnieppzqa@box> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Apr 2020, Yang Shi wrote: > On 4/30/20 2:59 PM, Kirill A. Shutemov wrote: > > On Thu, Apr 30, 2020 at 06:56:21AM +0800, Yang Shi wrote: > > > The max_ptes_{swap|none|shared} are defined to tune the behavior of > > > khugepaged. The are checked at a couple of places with open coding. > > > Replace the opencoding to exceed_pax_ptes_{swap|none_shared} helpers to > > > improve the readability. > > > > > > Cc: Kirill A. Shutemov > > > Cc: Hugh Dickins > > > Cc: Andrea Arcangeli > > > Signed-off-by: Yang Shi > > > --- > > > mm/khugepaged.c | 27 +++++++++++++++++++++------ > > > 1 file changed, 21 insertions(+), 6 deletions(-) > > > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > > index a02a4c5..0c8d30b 100644 > > > --- a/mm/khugepaged.c > > > +++ b/mm/khugepaged.c > > > @@ -339,6 +339,21 @@ struct attribute_group khugepaged_attr_group = { > > > }; > > > #endif /* CONFIG_SYSFS */ > > > +static inline bool exceed_max_ptes_none(unsigned int *nr_ptes) > > > +{ > > > + return (++(*nr_ptes) > khugepaged_max_ptes_none); > > > +} > > > + > > > +static inline bool exceed_max_ptes_swap(unsigned int *nr_ptes) > > > +{ > > > + return (++(*nr_ptes) > khugepaged_max_ptes_swap); > > > +} > > > + > > > +static inline bool exceed_max_ptes_shared(unsigned int *nr_ptes) > > > +{ > > > + return (++(*nr_ptes) > khugepaged_max_ptes_shared); > > > +} > > > + > > Frankly, I find this ugly and confusing. Open-coded version is more > > readable to me. Wow, yes, I strongly agree with Kirill. > > I'm sorry you feel that way. I tend to agree that dereference looks not good. > The open-coded version is not hard to understand to me either. > > They are checked at a couple of different places with different variables, > i.e. unmapped vs swap, and with different comparisons, > vs <=. I just > thought the helpers with unified name started with "exceed_" may make it more > self-explained and readable. Anyway this totally depends on taste and I > really don't insist on this change. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F7E1C47247 for ; Fri, 1 May 2020 01:09:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DDF9E2074A for ; Fri, 1 May 2020 01:09:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EtQaTk0B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDF9E2074A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 36D498E0005; Thu, 30 Apr 2020 21:09:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F6D58E0001; Thu, 30 Apr 2020 21:09:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BF0D8E0005; Thu, 30 Apr 2020 21:09:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0133B8E0001 for ; Thu, 30 Apr 2020 21:09:25 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A9C7352CC for ; Fri, 1 May 2020 01:09:25 +0000 (UTC) X-FDA: 76766367090.03.list70_35276e6855f1f X-HE-Tag: list70_35276e6855f1f X-Filterd-Recvd-Size: 5404 Received: from mail-oo1-f68.google.com (mail-oo1-f68.google.com [209.85.161.68]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 May 2020 01:09:25 +0000 (UTC) Received: by mail-oo1-f68.google.com with SMTP id g14so411602ooa.4 for ; Thu, 30 Apr 2020 18:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=iXrA9vjDFeyBPogW8X3baa2NAT1RG1h/25KrkcOYPyk=; b=EtQaTk0BIrN9hgAUH4jSlTrl+Q207os/So9AiKENej0LuanW8nWejAFjXnLoZlmeR4 +ti2sYQdpgMPGJECSbnhUmrLXyLoZY6Kug+Vm8v5u1KYOm1/Kof/C8kPVXJDo6GYJVf4 /Q0lpeQZtlf2xXJWWy/sLQ3Xob7UIbAf89bbCTboOcJ6FeSnst/Er7gUIummoUP9f9wX q973lmYcW9qE/wrQVMDaIkcwYZVY15iim0spYQ5SosKYH51UVqU+4baaNY/+xgBjJ5D+ 9xQTGq50SIxOcD8i9g20HwegFCYPdStZGHBi9DYnzp1jfK+2yDry22p+gi7cjRubBQSP u0nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=iXrA9vjDFeyBPogW8X3baa2NAT1RG1h/25KrkcOYPyk=; b=RDAnXeA1m20Sx7Nu6b5/M3GKm1nCKgUWoEHSN7ypOEk/PbYU0LoYtdL2iQmz4Kcwjw KEM4a2QfAVrQUL004SGODHv9NVSnzOe7ep1n3LEAGGJsydtHCsr7Rg5LfeoLjg+Cr3rN jXEko+b/QvUpD/1sBGLaGjqZ8Po1qJtgxg9u3jlT3qNOAAzpo/JrMftNHfk+sz/WfgfP bno7FZq4VU3WRDlsvGXMrCTtRvjTp8om0maGQT78TZkwS/VMv7cyPPucy/ikPpnMmXV6 cKfqIW4QF5EijvDyEJtSI+hZOK2djSQL0O6YnbuWsgME2dnblfqbkpITNwfVfL2OxdwP v3vQ== X-Gm-Message-State: AGi0PuZz346NYaEtxJ/JE22+vJZBVBfzF5ibOUkrgXp3YE0Uuj+pIJPE 5W5fwT0mQW68feJK1gBLGjWehQ== X-Google-Smtp-Source: APiQypJ+scBXw7K9Y+l1S2jlTS7e2TRgQUfk+9D2W+8cSGXvUZp1msNhnPw4lHxV9WnTP0XblZiwag== X-Received: by 2002:a4a:8253:: with SMTP id t19mr1736955oog.69.1588295364238; Thu, 30 Apr 2020 18:09:24 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id p17sm36208oot.17.2020.04.30.18.09.22 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Thu, 30 Apr 2020 18:09:22 -0700 (PDT) Date: Thu, 30 Apr 2020 18:09:03 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yang Shi cc: "Kirill A. Shutemov" , kirill.shutemov@linux.intel.com, hughd@google.com, aarcange@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [linux-next PATCH 1/2] mm: khugepaged: add exceed_max_ptes_* helpers In-Reply-To: Message-ID: References: <1588200982-69492-1-git-send-email-yang.shi@linux.alibaba.com> <20200430215932.5w5dck3rnieppzqa@box> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 30 Apr 2020, Yang Shi wrote: > On 4/30/20 2:59 PM, Kirill A. Shutemov wrote: > > On Thu, Apr 30, 2020 at 06:56:21AM +0800, Yang Shi wrote: > > > The max_ptes_{swap|none|shared} are defined to tune the behavior of > > > khugepaged. The are checked at a couple of places with open coding. > > > Replace the opencoding to exceed_pax_ptes_{swap|none_shared} helpers to > > > improve the readability. > > > > > > Cc: Kirill A. Shutemov > > > Cc: Hugh Dickins > > > Cc: Andrea Arcangeli > > > Signed-off-by: Yang Shi > > > --- > > > mm/khugepaged.c | 27 +++++++++++++++++++++------ > > > 1 file changed, 21 insertions(+), 6 deletions(-) > > > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > > index a02a4c5..0c8d30b 100644 > > > --- a/mm/khugepaged.c > > > +++ b/mm/khugepaged.c > > > @@ -339,6 +339,21 @@ struct attribute_group khugepaged_attr_group = { > > > }; > > > #endif /* CONFIG_SYSFS */ > > > +static inline bool exceed_max_ptes_none(unsigned int *nr_ptes) > > > +{ > > > + return (++(*nr_ptes) > khugepaged_max_ptes_none); > > > +} > > > + > > > +static inline bool exceed_max_ptes_swap(unsigned int *nr_ptes) > > > +{ > > > + return (++(*nr_ptes) > khugepaged_max_ptes_swap); > > > +} > > > + > > > +static inline bool exceed_max_ptes_shared(unsigned int *nr_ptes) > > > +{ > > > + return (++(*nr_ptes) > khugepaged_max_ptes_shared); > > > +} > > > + > > Frankly, I find this ugly and confusing. Open-coded version is more > > readable to me. Wow, yes, I strongly agree with Kirill. > > I'm sorry you feel that way. I tend to agree that dereference looks not good. > The open-coded version is not hard to understand to me either. > > They are checked at a couple of different places with different variables, > i.e. unmapped vs swap, and with different comparisons, > vs <=. I just > thought the helpers with unified name started with "exceed_" may make it more > self-explained and readable. Anyway this totally depends on taste and I > really don't insist on this change.