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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAD2DC433EF for ; Mon, 13 Jun 2022 05:48:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14B698D0153; Mon, 13 Jun 2022 01:48:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FBFB8D0142; Mon, 13 Jun 2022 01:48:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB7358D0153; Mon, 13 Jun 2022 01:48:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DC4058D0142 for ; Mon, 13 Jun 2022 01:48:50 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9B375351BF for ; Mon, 13 Jun 2022 05:48:50 +0000 (UTC) X-FDA: 79572133620.29.248A362 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf12.hostedemail.com (Postfix) with ESMTP id 025DA40092 for ; Mon, 13 Jun 2022 05:48:49 +0000 (UTC) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25D5FFCP037328; Mon, 13 Jun 2022 05:48:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=39W8RlxrwOaMEwVU56Gyx8hQG96IHYffjy4iH+NWIu0=; b=SMwwAo03iKeK4AspDY0tD6v0/sAxBa6MhFqY6B8cIr2WZlZHcafizwad0IuyD18YdijX lGCj7zAP84o8uP6QiPMOMJAZCJYLBCS1OLqYSbiFl18JfTteSjb4bXpECsP+w7rEq9/X UhErmOe34zc9s6ezhwB7ocv+kzCKINJnj8C58sLTR+sGhdeN2ZAw9snEP9rkX0bumRPZ VXm/OwKLzj/Yz3AqEI9WDmc7HxS9bA0F97TRre3EOo8pZWoDVlJyk3CuzF1oTDSIQEcd 6tr4Hrklb2/z788pEsiLyYExM1Iry/eU8sMWRbBWT2uW9zT1LsfB/MKErR7tC5p+Fgah cw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gn53qgk6w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jun 2022 05:48:37 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25D5jU1c016687; Mon, 13 Jun 2022 05:48:36 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gn53qgk6k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jun 2022 05:48:36 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25D5ablv013329; Mon, 13 Jun 2022 05:48:34 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3gmjaja7ey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jun 2022 05:48:34 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25D5mWnx17564066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jun 2022 05:48:32 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 044EBA405F; Mon, 13 Jun 2022 05:48:32 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9BA6A405C; Mon, 13 Jun 2022 05:48:25 +0000 (GMT) Received: from [9.43.31.74] (unknown [9.43.31.74]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 13 Jun 2022 05:48:25 +0000 (GMT) Message-ID: Date: Mon, 13 Jun 2022 11:18:23 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v6 03/13] mm/demotion: Return error on write to numa_demotion sysfs Content-Language: en-US To: Ying Huang , linux-mm@kvack.org, akpm@linux-foundation.org Cc: Wei Xu , Greg Thelen , Yang Shi , Davidlohr Bueso , Tim C Chen , Brice Goglin , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Alistair Popple , Dan Williams , Feng Tang , Jagdish Gediya , Baolin Wang , David Rientjes References: <20220610135229.182859-1-aneesh.kumar@linux.ibm.com> <20220610135229.182859-4-aneesh.kumar@linux.ibm.com> <7ed1f9f544937b5c82ab380a4977e5ae22a98c43.camel@intel.com> <9da3c6ef-ba0d-6229-2188-0956222b04f1@linux.ibm.com> <33b42a802a07721c639db99ed208ed43f743bb37.camel@intel.com> From: Aneesh Kumar K V In-Reply-To: <33b42a802a07721c639db99ed208ed43f743bb37.camel@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jgh2KiALuHqjNDHhb_MdO_XDgKx05fcS X-Proofpoint-ORIG-GUID: gHN1GEzleRD5iJChut3EoOhIQu4ngYnv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-13_02,2022-06-09_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 priorityscore=1501 phishscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 malwarescore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206130026 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655099330; a=rsa-sha256; cv=none; b=DVnW3JiMETbcC5p+7Tj0abpHcssGQ+pkqf57HPQFRsW9oHbjFrT/A+JDHlanZq8dZx6Qyu 2kt18ccAgpfvhzcbwfZBMO9AwDqJIB4ZXwaC7alpSpBkzbPR+wuMe5/5h9sUtHJdhlHYaq jALPB72YTOHcn4txhk04y2jHJTTILj8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=SMwwAo03; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf12.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655099330; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=39W8RlxrwOaMEwVU56Gyx8hQG96IHYffjy4iH+NWIu0=; b=ixC0oaDRDGUEl1eAnYWRagRD9+io5yUoqs0YW3tANWEnUI5C6cC8dSPezWjIbjSv3+91t3 GO6KwTSZCOL7UjM9R2mvDg+yBJwQne9yKNPzxw1tMFH2yoZcrnWRkYKktmzlOprK6Jj6po lKr2kX3hGv/Xky7RnP2dK/yZFZMeN/U= X-Rspamd-Queue-Id: 025DA40092 X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=SMwwAo03; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf12.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com X-Stat-Signature: 6rhm8ckudpgwosqzqin61567xagsm1fp X-Rspamd-Server: rspam02 X-HE-Tag: 1655099329-496453 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 6/13/22 11:03 AM, Ying Huang wrote: > On Mon, 2022-06-13 at 09:05 +0530, Aneesh Kumar K V wrote: >> On 6/13/22 8:56 AM, Ying Huang wrote: >>> On Fri, 2022-06-10 at 19:22 +0530, Aneesh Kumar K.V wrote: >>>> With CONFIG_MIGRATION disabled return EINVAL on write. >>>> >>>> Signed-off-by: Aneesh Kumar K.V >>>> --- >>>>   mm/memory-tiers.c | 3 +++ >>>>   1 file changed, 3 insertions(+) >>>> >>>> diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c >>>> index 9c6b40d7e0bf..c3123a457d90 100644 >>>> --- a/mm/memory-tiers.c >>>> +++ b/mm/memory-tiers.c >>>> @@ -105,6 +105,9 @@ static ssize_t numa_demotion_enabled_store(struct kobject *kobj, >>>>   { >>>>    ssize_t ret; >>>> >>>> >>>> >>>> + if (!IS_ENABLED(CONFIG_MIGRATION)) >>>> + return -EINVAL; >>>> + >>> >>> How about enclose numa_demotion_enabled_xxx related code with CONFIG_MIGRATION? >>> >> >> IIUC there is a desire to use IS_ENABLED() in the kernel instead of >> #ifdef since that helps in more compile time checks. Because there are >> no dead codes during compile now with IS_ENABLED(). > > IS_ENABLED() is used to reduce usage of "#ifdef" in ".c" file, > especially inside a function. We have good build test coverage with > 0Day now. > > To avoid code size inflate, it's better to use #ifdef CONFIG_MIGRATION. > For a diff like below I am finding IS_ENABLED better. size memory-tiers.o.isenabled memory-tiers.o text data bss dec hex filename 4776 989 5 5770 168a memory-tiers.o.isenabled 5257 990 5 6252 186c memory-tiers.o modified mm/memory-tiers.c @@ -710,12 +710,11 @@ static int __meminit migrate_on_reclaim_callback(struct notifier_block *self, static void __init migrate_on_reclaim_init(void) { - - if (IS_ENABLED(CONFIG_MIGRATION)) { +#ifdef CONFIG_MIGRATION node_demotion = kcalloc(MAX_NUMNODES, sizeof(struct demotion_nodes), GFP_KERNEL); WARN_ON(!node_demotion); - } +#endif hotplug_memory_notifier(migrate_on_reclaim_callback, 100); } @@ -844,14 +843,19 @@ static ssize_t numa_demotion_enabled_show(struct kobject *kobj, numa_demotion_enabled ? "true" : "false"); } +#ifdef CONFIG_MIGRATION static ssize_t numa_demotion_enabled_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { - ssize_t ret; - - if (!IS_ENABLED(CONFIG_MIGRATION)) - return -EINVAL; + return -EINVAL; +} +#else +static ssize_t numa_demotion_enabled_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + ssize_t ret; ret = kstrtobool(buf, &numa_demotion_enabled); if (ret) @@ -859,6 +863,7 @@ static ssize_t numa_demotion_enabled_store(struct kobject *kobj, return count; } +#endif static struct kobj_attribute numa_demotion_enabled_attr = __ATTR(demotion_enabled, 0644, numa_demotion_enabled_show, I also find that #ifdef config not easier to the eyes. If there is a large code that we can end up #ifdef out, then it might be worth it. IIUC, we might want to keep the establish_migration target to find top_tier rank and lower_tier mask. Once we do that only thing that we could comment out is the node_demotion sysfs creation and I was considering to keep that even if migration is disabled with a write to the file returning EINVAL. I could switch that if you strongly feel that we should hide node_demotion sysfs file. -aneesh