Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp875612pxb; Fri, 22 Apr 2022 13:11:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrIa+zkeo6LmtSRFZDNJPcRLhey+Lk2hIUjgAVpc5SpICo8FBjhNiqrkjPPUhbvlp071P6 X-Received: by 2002:a05:6a00:234f:b0:4fa:f52b:46a1 with SMTP id j15-20020a056a00234f00b004faf52b46a1mr6698929pfj.32.1650658306102; Fri, 22 Apr 2022 13:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650658306; cv=none; d=google.com; s=arc-20160816; b=1F3Gdc9Z55NM0SWvRE5RPoBFJc9vUM+HyTylOGG7SF/cqAEbdbQgbipvnZjCuFs6rY Unn2aamW4KPrRb02GZ38hsZ/ADhMgoD7NxTJdXgEazPAoWgByEOpoxqpT0X7ahI79Hyh GoEoc+KOVeUSnSOsPKC5kO9DU7b0TaBx4qYQw623f6yw/3kxJZ4ONytV0iwQLKLnfXfB bpcnD260VENGywX/GTOyOjm/qDd5tzx37LF7T7xrqq4yN1gaGlyNp6IHZyPYx5r8tFsl vfCRj8wQy9XfCjCMOSPCWE5W42lBn5UbAjX18fTV0/cJpEPLBV1hCcHSrUvCNWoZRY+8 55kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mxeNHXPH62p1MM3dViS8VMAv5lfRWtwrnUsQzK/+pk0=; b=fa09YWcS5Hz4b1pvVBpVCLfKbgv5a7mNnFM674mbnjfijrBq14wWXsezoXYXvEU8lg NGqPoh7JMBnhFbZZOLKBb0O2S+7KEY4SoYLSTrggSHjOtBgM2ZoqNBeOF9CSPnDPsW12 bfyTy9R8e/ByzOZSvso5gmc/q8XUHzrGpE3xHsQERlQSrPXY7wAmsn7t+0MU0rSksehz eVt9T9mFuvJwoUo69oN/YMw2Z6ji6y82Af/L3LeaJ4U1xKnAtivnttRdyP19KoH02RTf NyId6ZHbG2GbbfmBvMoECVyNDRDQJsFGM7uwF02LyX2qJ2NWCjnBxshVS0YoU/XGM24n 8CVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hpb65DWD; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u7-20020a170903124700b0015498a2b02bsi9649313plh.316.2022.04.22.13.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 13:11:46 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hpb65DWD; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 66DBD265E05; Fri, 22 Apr 2022 12:10:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbiDUE3q (ORCPT + 99 others); Thu, 21 Apr 2022 00:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384102AbiDUE3h (ORCPT ); Thu, 21 Apr 2022 00:29:37 -0400 Received: from mail-ua1-x930.google.com (mail-ua1-x930.google.com [IPv6:2607:f8b0:4864:20::930]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBEB812600 for ; Wed, 20 Apr 2022 21:26:46 -0700 (PDT) Received: by mail-ua1-x930.google.com with SMTP id m19so1385871uao.1 for ; Wed, 20 Apr 2022 21:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mxeNHXPH62p1MM3dViS8VMAv5lfRWtwrnUsQzK/+pk0=; b=hpb65DWDNKWCr5K1UTnRgPuiUqPq07LZqLpUdOA/e/ZyiGO/WzZgPYchIFpzkCHtCn 7exSLTGUj9XRy6FwX6tZFQbEnPPFXUhH+fAkKwJTL5JuQl17w+FzTCX684ieIIuz0jMu TojJq6o/GFGIC0ewKPSErd/7hlxnMbFe7EnOJnOVmlGOrmSZrAXtyQdnlP8Ldc7+qzo3 /2vqlHcEq8oFsKzgI5weLRywsxbIjxQZGweg/f0FAQSTgV3Ps9nya9on/achYoLpYk3L OGwF4N7IjFeoiQpm6IVAAsznlt0igAZHMTruvifVvuSxMusXbyNwrj5hGQHSHYSt4mp/ 6R3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mxeNHXPH62p1MM3dViS8VMAv5lfRWtwrnUsQzK/+pk0=; b=DJlt8yGq0p+fiXytVNkpA4aVNmuGDDfWbOCkbJIM+/+/LTG7IwvSPSe/IBPnR/CQXp 7Gm5VePhWGKivy3ORmW7Tq6w5OW1JtSkzriQwQrNmqYQV7AOLAfJwYr907z03gnILISE FlHLRD9xSRkZS08yIE3Ko+nqof4m60mqVKZW5pFBXS5UQ4RNy2PQ7ZDRXsnb8wdy7IPz TnJ+A0/BX1971jiojiOFY75E+VBvFKvKSr0w5ANg3d7WoGFbcU09y/pV1e5/iqbNzdok 1YPz8G/RW6QZZATemARK6fmUmgdSK2evq108UdiMJm4apfQ1CfRYetqAqejTpwGegzGL /Y+A== X-Gm-Message-State: AOAM532EdNbuNhz9RNWwLEZc18LTUMwBlh3ccZ5/dfBLVCLhuAPKjHgP Yay3jm/h5cLGMosOjDRr6c87TMZzpiqP+koX8QhnFw== X-Received: by 2002:a9f:2046:0:b0:35d:bfc:2c9 with SMTP id 64-20020a9f2046000000b0035d0bfc02c9mr6754804uam.119.1650515205811; Wed, 20 Apr 2022 21:26:45 -0700 (PDT) MIME-Version: 1.0 References: <20220413092206.73974-1-jvgediya@linux.ibm.com> <20220413092206.73974-4-jvgediya@linux.ibm.com> In-Reply-To: <20220413092206.73974-4-jvgediya@linux.ibm.com> From: Wei Xu Date: Wed, 20 Apr 2022 21:26:34 -0700 Message-ID: Subject: Re: [PATCH v2 3/5] mm: demotion: Add support to set targets from userspace To: Jagdish Gediya Cc: Linux MM , Linux Kernel Mailing List , Andrew Morton , aneesh.kumar@linux.ibm.com, Baolin Wang , Dave Hansen , Huang Ying , Greg Thelen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 13, 2022 at 2:22 AM Jagdish Gediya wrote: > > Add support to set node_states[N_DEMOTION_TARGETS] from > user space to override the default demotion targets. > > Restrict demotion targets to memory only numa nodes > while setting them from user space. Why should we restrict demotion targets to memory only nodes if they get set explicitly from user space? For example, if we use NUMA emulation to test demotion without actual hardware, these emulated NUMA nodes can have CPUs, but we still want some of them to serve as demotion targets. > Demotion targets can be set from userspace using command, > echo > /sys/kernel/mm/numa/demotion_target > > Signed-off-by: Aneesh Kumar K.V > Signed-off-by: Jagdish Gediya > --- > .../ABI/testing/sysfs-kernel-mm-numa | 12 +++++++ > mm/migrate.c | 35 +++++++++++++++++++ > 2 files changed, 47 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-numa b/Documentation/ABI/testing/sysfs-kernel-mm-numa > index 77e559d4ed80..10e9e643845c 100644 > --- a/Documentation/ABI/testing/sysfs-kernel-mm-numa > +++ b/Documentation/ABI/testing/sysfs-kernel-mm-numa > @@ -22,3 +22,15 @@ Description: Enable/disable demoting pages during reclaim > the guarantees of cpusets. This should not be enabled > on systems which need strict cpuset location > guarantees. > + > +What: /sys/kernel/mm/numa/demotion_target > +Date: April 2022 > +Contact: Linux memory management mailing list > +Description: Configure demotion target nodes > + > + Page migration during reclaim is intended for systems > + with tiered memory configurations. Preferred migration target > + nodes can be configured in a system using this interface, based > + on which demotion table is prepared in kernel. If demotion is > + enabled then pages will be migrated to set demotion targets > + during reclaim. > diff --git a/mm/migrate.c b/mm/migrate.c > index 516f4e1348c1..4d3d80ca0a7f 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2564,12 +2564,47 @@ static ssize_t numa_demotion_enabled_store(struct kobject *kobj, > return count; > } > > + > +static ssize_t numa_demotion_target_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > +{ > + return sysfs_emit(buf, "%*pbl\n", > + nodemask_pr_args(&node_states[N_DEMOTION_TARGETS])); > +} > + > +static ssize_t numa_demotion_target_store(struct kobject *kobj, > + struct kobj_attribute *attr, > + const char *nodelist, size_t count) > +{ > + nodemask_t nodes; > + > + if (nodelist_parse(nodelist, nodes)) > + return -EINVAL; > + > + if (!nodes_subset(nodes, node_states[N_MEMORY])) > + return -EINVAL; > + > + if (nodes_intersects(nodes, node_states[N_CPU])) > + return -EINVAL; > + > + node_states[N_DEMOTION_TARGETS] = nodes; > + > + set_migration_target_nodes(); > + > + return count; > +} > + > static struct kobj_attribute numa_demotion_enabled_attr = > __ATTR(demotion_enabled, 0644, numa_demotion_enabled_show, > numa_demotion_enabled_store); > > +static struct kobj_attribute numa_demotion_target_attr = > + __ATTR(demotion_target, 0644, numa_demotion_target_show, > + numa_demotion_target_store); > + > static struct attribute *numa_attrs[] = { > &numa_demotion_enabled_attr.attr, > + &numa_demotion_target_attr.attr, > NULL, > }; > > -- > 2.35.1 > >