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 A5A57C3DA70 for ; Mon, 22 Jul 2024 06:14:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1BF96B0082; Mon, 22 Jul 2024 02:14:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECBA06B0083; Mon, 22 Jul 2024 02:14:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBABB6B0085; Mon, 22 Jul 2024 02:14:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BEE996B0082 for ; Mon, 22 Jul 2024 02:14:07 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 35B1F1A14B5 for ; Mon, 22 Jul 2024 06:14:07 +0000 (UTC) X-FDA: 82366373334.15.ACB7E6B Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) by imf05.hostedemail.com (Postfix) with ESMTP id 2C756100010 for ; Mon, 22 Jul 2024 06:14:03 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=YRYkEzZJ; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf05.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.98 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721628808; a=rsa-sha256; cv=none; b=fKfkRRHWJqi3HmaQWLWraNV2qrIXXNuyV40zgBfr6TJ+igHLxvqKPbvIBoISgVPKcaFjat CGHNpk18Kb1TtIu77YzhnhOaXj2LSLJfzP8ZNiVJpVLcKkaLh9BEit34ixBLNmjXwacud+ 46HZD2X01GYjkl+OpOmXopo8BuGDKPc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=YRYkEzZJ; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf05.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.98 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721628808; 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=psWoa8gs4DgPKMVzS4Tt55VRNtl5XNEvd7BQaoJFa24=; b=XY2RnayhpWlavtD4a4sUGxSxt38FAKtUOJl+Fxx47DzdtCuSSPqKQoEaCSem+i+INmn+O7 Sk6GZYu7lEKIUPBj9bfrRMoMeqgYzuWq+sjoaNxwfe0z932tiBTZWAEL3HsK0mx853Oy5N RjRdECIkG3OJ4W8penhVJwdjAnrxryc= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1721628841; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=psWoa8gs4DgPKMVzS4Tt55VRNtl5XNEvd7BQaoJFa24=; b=YRYkEzZJ4FgcamX2Z/BGSZ20bCuAWzzBba6rviBTM6fU0PxuLyfzWPWRk3g+l6ZRqWis1+GzjpbFqA0J/3l6RlMgKHaYiHtgfZ42qJP3Vfoq/3ANop8QZnPI6eGXjboF7ujWXjLnF1de7vNIUs9RstFFNNtwwZ/w8CBIOuvy0/U= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R801e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067111;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0WAzT8Iy_1721628840; Received: from 30.97.56.74(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WAzT8Iy_1721628840) by smtp.aliyun-inc.com; Mon, 22 Jul 2024 14:14:01 +0800 Message-ID: <9a7c863d-b64e-4278-bb5b-db777736ab6e@linux.alibaba.com> Date: Mon, 22 Jul 2024 14:14:00 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/3] mm: Tidy up shmem mTHP controls and stats To: Ryan Roberts , Andrew Morton , Hugh Dickins , Jonathan Corbet , "Matthew Wilcox (Oracle)" , David Hildenbrand , Barry Song , Lance Yang , Gavin Shan Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20240716135907.4047689-1-ryan.roberts@arm.com> <20240716135907.4047689-3-ryan.roberts@arm.com> From: Baolin Wang In-Reply-To: <20240716135907.4047689-3-ryan.roberts@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2C756100010 X-Stat-Signature: 7i4x5rr1hqnn17ryex5g4gacripa7d7c X-Rspam-User: X-HE-Tag: 1721628843-619043 X-HE-Meta: U2FsdGVkX1/9PpHHBAcDE2Jdo35B72UC25SZckT12M6Lxmxn2f3GvqslJOFspydX8kQc/vl3SA0tAVyXPx2ROzRjn7ujekg8sxCziSzqKn7n4kw7gUKVJK+d2dhgo/ET/HvQ3+kjjZ8BvwxEPkJhTk/HsFut/Letr/J3ikueGgt0Qap8zY0ZCZjmS+cq+qHHz9tdzuAnkpBc0fUjFEsxGsjNkJ5Z9DK5XlgLnX1TuQ+0qFLxVN4bj2vyNoIhrEm9liWJRaP9zjNlxlXYTA6uxVTc/jqwk5PeHx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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2024/7/16 21:59, Ryan Roberts wrote: > Previously we had a situation where shmem mTHP controls and stats were > not exposed for some supported sizes and were exposed for some > unsupported sizes. So let's clean that up. > > Anon mTHP can support all large orders (2, PMD_ORDER). But shmem can > support all large orders (1, MAX_PAGECACHE_ORDER). However, per-size > shmem controls and stats were previously being exposed for all the anon > mTHP orders, meaning order-1 was not present, and for arm64 64K base > pages, orders 12 and 13 were exposed but were not supported internally. > > Tidy this all up by defining ctrl and stats attribute groups for anon > and file separately. Anon ctrl and stats groups are populated for all > orders in THP_ORDERS_ALL_ANON and file ctrl and stats groups are > populated for all orders in THP_ORDERS_ALL_FILE_DEFAULT. Make sense. > > The side-effect of all this is that different hugepage-*kB directories > contain different sets of controls and stats, depending on which memory > types support that size. This approach is preferred over the > alternative, which is to populate dummy controls and stats for memory > types that do not support a given size. OK. > > Signed-off-by: Ryan Roberts > --- > mm/huge_memory.c | 110 ++++++++++++++++++++++++++++++++++------------- > 1 file changed, 80 insertions(+), 30 deletions(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index f4be468e06a4..578ac212c172 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -463,8 +463,8 @@ static void thpsize_release(struct kobject *kobj); > static DEFINE_SPINLOCK(huge_anon_orders_lock); > static LIST_HEAD(thpsize_list); > > -static ssize_t thpsize_enabled_show(struct kobject *kobj, > - struct kobj_attribute *attr, char *buf) > +static ssize_t anon_enabled_show(struct kobject *kobj, > + struct kobj_attribute *attr, char *buf) > { > int order = to_thpsize(kobj)->order; > const char *output; > @@ -481,9 +481,9 @@ static ssize_t thpsize_enabled_show(struct kobject *kobj, > return sysfs_emit(buf, "%s\n", output); > } > > -static ssize_t thpsize_enabled_store(struct kobject *kobj, > - struct kobj_attribute *attr, > - const char *buf, size_t count) > +static ssize_t anon_enabled_store(struct kobject *kobj, > + struct kobj_attribute *attr, > + const char *buf, size_t count) > { > int order = to_thpsize(kobj)->order; > ssize_t ret = count; > @@ -525,19 +525,27 @@ static ssize_t thpsize_enabled_store(struct kobject *kobj, > return ret; > } > > -static struct kobj_attribute thpsize_enabled_attr = > - __ATTR(enabled, 0644, thpsize_enabled_show, thpsize_enabled_store); > +static struct kobj_attribute anon_enabled_attr = > + __ATTR(enabled, 0644, anon_enabled_show, anon_enabled_store); > > -static struct attribute *thpsize_attrs[] = { > - &thpsize_enabled_attr.attr, > +static struct attribute *anon_ctrl_attrs[] = { > + &anon_enabled_attr.attr, > + NULL, > +}; > + > +static const struct attribute_group anon_ctrl_attr_grp = { > + .attrs = anon_ctrl_attrs, > +}; > + > +static struct attribute *file_ctrl_attrs[] = { > #ifdef CONFIG_SHMEM > &thpsize_shmem_enabled_attr.attr, > #endif > NULL, > }; > > -static const struct attribute_group thpsize_attr_group = { > - .attrs = thpsize_attrs, > +static const struct attribute_group file_ctrl_attr_grp = { > + .attrs = file_ctrl_attrs, > }; > > static const struct kobj_type thpsize_ktype = { > @@ -583,57 +591,99 @@ DEFINE_MTHP_STAT_ATTR(split, MTHP_STAT_SPLIT); > DEFINE_MTHP_STAT_ATTR(split_failed, MTHP_STAT_SPLIT_FAILED); > DEFINE_MTHP_STAT_ATTR(split_deferred, MTHP_STAT_SPLIT_DEFERRED); > > -static struct attribute *stats_attrs[] = { > +static struct attribute *anon_stats_attrs[] = { > &anon_fault_alloc_attr.attr, > &anon_fault_fallback_attr.attr, > &anon_fault_fallback_charge_attr.attr, > &swpout_attr.attr, > &swpout_fallback_attr.attr, > - &shmem_alloc_attr.attr, > - &shmem_fallback_attr.attr, > - &shmem_fallback_charge_attr.attr, > &split_attr.attr, > &split_failed_attr.attr, > &split_deferred_attr.attr, > NULL, > }; > > -static struct attribute_group stats_attr_group = { > +static struct attribute_group anon_stats_attr_grp = { > + .name = "stats", > + .attrs = anon_stats_attrs, > +}; > + > +static struct attribute *file_stats_attrs[] = { > +#ifdef CONFIG_SHMEM > + &shmem_alloc_attr.attr, > + &shmem_fallback_attr.attr, > + &shmem_fallback_charge_attr.attr, Shmem should also support swpout_* counters.