Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5440552rdb; Wed, 13 Dec 2023 08:42:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/Xylp88Cg5gU4lMS2ipOR4XtgRDIrXcvn+NCzE1TUGgKmMRMp66rpKNyE03JwlBh2sM/0 X-Received: by 2002:a17:90a:c90a:b0:28a:f90f:9bd3 with SMTP id v10-20020a17090ac90a00b0028af90f9bd3mr361060pjt.77.1702485723253; Wed, 13 Dec 2023 08:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702485723; cv=none; d=google.com; s=arc-20160816; b=jnMmgWwO1UDb6anUGYNKeeJmDA33hO+P0v7hjZS9Mg5bgrh3L1ibbv2erBajguzbp1 DSSMCuwwFiQOtLcmFd6x79SFANnanv+le/6peaBz8Ja7olm+VsN51AXJVdRV+BOys6IA 2Lc5h8nf/xxwwjyDL3GDAD5R1deNe4Yfzvv29IWg0kKKBeoWuJITb50XIJeIWfcfh0OK BbKC/drNVWuUpCs/1ji2pbFtRvCkTXvmaOcJHmpfRuEIHJEniWHRkV5Aln+N2uZBtobc qgh9OW8+/7TJQmdux/8J4XlANBe6cKxvjX+SF2K/Cex5PjhspN2JzSsHcTeI5nUVF4Z4 OW7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gr+U3ThNAiG15ak/Lw3/3fJKchrsxVjpre1fxBodeHk=; fh=W6Q6Vd25CSbUZKv6PPQhzmXsxEuqs9kr4WQV9z1wK0s=; b=h4uJ9u9k6ko3XLcDMcGT6hWAIOcHAAZNf3hpvxttMPadfHH4M7qBP8VRQMxQ/FRtw4 PlS2sLvce3HVoAqiBS+C2tj1RnBCoWafPerNebsMUw3v1fkMVkFuRqrkmEwmNChPrD47 E0UtqEpmUKXYHOFpwIjj+JbS7QIMrkHq3c3jQ5R6eVoGME0sKdKGJAc9s0Q9od3LKMCO 5hLqpF8PCtk+F/hF+kAAKEVL0btbLzr70rR7GAGke2v5oAko75bONSdMKWNdghu+Z1XN QJPt2YIok6B+GazSicAf5hNeYyTqrQFmaPaywQYSmQN0d3VvUWhj4zrgjzxiULwJ57h/ 4Rlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=i5fNo+ZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id lt9-20020a17090b354900b0028ac561f336si2715227pjb.43.2023.12.13.08.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 08:42:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=i5fNo+ZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3A179803215C; Wed, 13 Dec 2023 08:41:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbjLMQlm (ORCPT + 99 others); Wed, 13 Dec 2023 11:41:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbjLMQll (ORCPT ); Wed, 13 Dec 2023 11:41:41 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F61F98; Wed, 13 Dec 2023 08:41:47 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5be30d543c4so4014821a12.2; Wed, 13 Dec 2023 08:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702485707; x=1703090507; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=gr+U3ThNAiG15ak/Lw3/3fJKchrsxVjpre1fxBodeHk=; b=i5fNo+ZRR2bjx4Ux+fmAKRYYZYjY6ihAzf3O46GVHgCHMjl8I5YuNa0CzUfxwpstVK x6OWaFD8K8FUa0l6T4DEjQNt+R8ULgcLggNArT1fp1EIVTPx5p2wR2ISpiNIBkITQqPw IoXncIfo3zNax4jjaMWaeTJBcZRseOHkAdUqbGYeY+jx+joj8T++/czndYrSi0CPJfcL qGcUqmF52KKTqtu0lGcKDshlNolfyAm9zDDdFgPoysAG72ldkGfrnAt+fqBW5I3+v+R8 WweJREcSLmZlsmoOm6xtDQSGvl6K8l1nyz3XkwOvMVXC3j0ph9qWu0h3rULn0w7P0EBm hs9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702485707; x=1703090507; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gr+U3ThNAiG15ak/Lw3/3fJKchrsxVjpre1fxBodeHk=; b=WeBAZIqm5iLMq/5aaCLUROiqINqQe5KltwmErd6dIsMN3GiIClHYgfxrO4FKI0TAyK Pwn2aVUgZRLPU3mLl8YY7L+x43WHkPHWF+tav5J350Rho8zjM/Df/9PkemQn/fwwl+qu 9lJo6aJFmZM/MzUP5opzr2J7NlrwrOjb7Y9kpalbUb7tgY6n4PqP6ojhzPgywuHxT4oh YYgh9Pb7kfGNk/VDc4YVLM4xOPmKwgjGmzWkbFtZmxVh4WmQO1qBTcqQOT8hfocVFKhm uOMsPm6w8xHwuJBF7rTFRX13lp/gMKE4DhohRZMCTAtyFAEatoSIbMkq4nu2reoZ+yS/ h0fA== X-Gm-Message-State: AOJu0Yy0YdSKQJHEo5ZqoZIypnNFnrbIXBpoivb6qNcM/LdFKry2RPmK DP/H+AFDCXQUK+NdMUoLep0= X-Received: by 2002:a05:6a21:7802:b0:191:e72c:24cf with SMTP id be2-20020a056a21780200b00191e72c24cfmr422281pzc.31.1702485706573; Wed, 13 Dec 2023 08:41:46 -0800 (PST) Received: from dschatzberg-fedora-PF3DHTBV ([2620:10d:c090:500::5:4500]) by smtp.gmail.com with ESMTPSA id s35-20020a056a0017a300b006d0bff2cc81sm2027359pfg.123.2023.12.13.08.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 08:41:44 -0800 (PST) Date: Wed, 13 Dec 2023 11:41:41 -0500 From: Dan Schatzberg To: Huan Yang <11133793@vivo.com> Cc: Johannes Weiner , Roman Gushchin , Yosry Ahmed , Huan Yang , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Tejun Heo , Zefan Li , Jonathan Corbet , Michal Hocko , Shakeel Butt , Muchun Song , Andrew Morton , David Hildenbrand , Matthew Wilcox , Chris Li , Kefeng Wang , Yue Zhao , Hugh Dickins Subject: Re: [PATCH V4 1/2] mm: add defines for min/max swappiness Message-ID: References: <20231213013807.897742-1-schatzberg.dan@gmail.com> <20231213013807.897742-2-schatzberg.dan@gmail.com> <86984d9b-c955-4b06-9097-2a757b1bacfe@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86984d9b-c955-4b06-9097-2a757b1bacfe@vivo.com> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Dec 2023 08:41:57 -0800 (PST) On Wed, Dec 13, 2023 at 09:58:26AM +0800, Huan Yang wrote: > > 在 2023/12/13 9:38, Dan Schatzberg 写道: > > [????????? schatzberg.dan@gmail.com ????????? https://aka.ms/LearnAboutSenderIdentification,????????????] > > > > We use the constants 0 and 200 in a few places in the mm code when > > referring to the min and max swappiness. This patch adds MIN_SWAPPINESS > > and MAX_SWAPPINESS #defines to improve clarity. There are no functional > > changes. > > > > Signed-off-by: Dan Schatzberg > > --- > > include/linux/swap.h | 2 ++ > > mm/memcontrol.c | 2 +- > > mm/vmscan.c | 10 +++++----- > > 3 files changed, 8 insertions(+), 6 deletions(-) > > > > diff --git a/include/linux/swap.h b/include/linux/swap.h > > index f6dd6575b905..e2ab76c25b4a 100644 > > --- a/include/linux/swap.h > > +++ b/include/linux/swap.h > > @@ -407,6 +407,8 @@ extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, > > > > #define MEMCG_RECLAIM_MAY_SWAP (1 << 1) > > #define MEMCG_RECLAIM_PROACTIVE (1 << 2) > > +#define MIN_SWAPPINESS 0 > > +#define MAX_SWAPPINESS 200 > > Do MAX_SWAPPINESS apply for all swapppiness? If so, maybe better change > swappiness sysctl define: > ``` > sysctl.c: > > { >         .procname    = "swappiness", >         .data        = &vm_swappiness, >         .maxlen        = sizeof(vm_swappiness), >         .mode        = 0644, >         .proc_handler    = proc_dointvec_minmax, >         .extra1        = SYSCTL_ZERO, >         .extra2        = SYSCTL_TWO_HUNDRED, >     }, > > ``` > > Here hard code swappiness in [0, 200], and now add a new define. Yes, MAX_SWAPPINESS is a hard limit. I'm not sure what you're proposing here - the SYSCTL_ZERO and SYSCTL_TWO_HUNDRED values are a little different than the defines I added. I think most of the value is just consistently using the defines in the core mm code. > > And many other code hard reference 200 into max value of swappiness, like: > > ``` > memcontrol.c: > static int mem_cgroup_swappiness_write(struct cgroup_subsys_state *css, >                        struct cftype *cft, u64 val) > { >     struct mem_cgroup *memcg = mem_cgroup_from_css(css); > >     if (val > 200) >         return -EINVAL; > >     if (!mem_cgroup_is_root(memcg)) >         memcg->swappiness = val; >     else >         vm_swappiness = val; > >     return 0; > } This one is already fixed in my patch.