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 0A594C3DA5D for ; Mon, 22 Jul 2024 07:33:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 912CE6B0083; Mon, 22 Jul 2024 03:33:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C32D6B008C; Mon, 22 Jul 2024 03:33:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D8EB6B0092; Mon, 22 Jul 2024 03:33:12 -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 6209E6B0083 for ; Mon, 22 Jul 2024 03:33:12 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2839516157D for ; Mon, 22 Jul 2024 07:33:12 +0000 (UTC) X-FDA: 82366572624.19.C890A3D Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id D16E21A0013 for ; Mon, 22 Jul 2024 07:33:09 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721633545; 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; bh=GkGVPB83GbzLSBjfX8EspplKIQ2j3li11V7z80KL3ck=; b=wRpmkKBJ9ysRaz9WTq9I9fNOPe21UTUCnAJSIdFJ64g5ekokM5EKCBv6HDu85QZYADCnik sbqy8UCvGfeZ4y/E4TDoVGrkoWeLY1vnSfOUq82DtN8WhacWLahP4j70q9EdJdUsC+sHGQ WjKgyyo6yydHOPGYNxn8fON8UrF4ll0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721633545; a=rsa-sha256; cv=none; b=szFtpGROdtuuQA+i/KzoJldlUROnF/Dc98EghIv0HOcVe5d8otC7M/CwdHMBosOku3ZqT9 WRdfCd9qSJbArJXu3VTvvV9iu7zcXx6W1yigL4BiLnFzgnWkjR8BkcuCWroDsAV/M89bis gtaQ6S+HciYA5NCEbpfFqNW+x2q7U8Q= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3ABCEFEC; Mon, 22 Jul 2024 00:33:34 -0700 (PDT) Received: from [10.57.77.243] (unknown [10.57.77.243]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 541E53F766; Mon, 22 Jul 2024 00:33:07 -0700 (PDT) Message-ID: <1732c37b-ab9d-47f7-8bfe-cc7992b632cf@arm.com> Date: Mon, 22 Jul 2024 08:33:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/3] mm: Tidy up shmem mTHP controls and stats Content-Language: en-GB To: Baolin Wang , 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> <9a7c863d-b64e-4278-bb5b-db777736ab6e@linux.alibaba.com> From: Ryan Roberts In-Reply-To: <9a7c863d-b64e-4278-bb5b-db777736ab6e@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D16E21A0013 X-Stat-Signature: g56giqwhae9hookm9jhrmcg9x17s37aq X-HE-Tag: 1721633589-745319 X-HE-Meta: U2FsdGVkX19zsbigz4+MtxVz+TjkApKs1S1KsvYwiFIhedeLDbt1x4s5370VqRLFoMkisZbUFnPTELqXOoTlKQN+YBavmoL36Yyz6okaQm+zctccPwsREqHVHMY1Mtshj9GySLopTXoeqNqHuSpoEEEnVAkH3nozExvgdegWskDp/RW8a1bkMJCJE4QA3/ZtNTGec0pW1oG0pjU0PFs5tO3oJ8qmJ2XFhBTLNBfV76oayzgeX6TxacdP2yQSP4BWGq0YTlWxwx3Zg6iCuecmT4jEO1Rh6PbUNxHDsIKZmDuOaPeqaW3wl0NeASzCxUFveH+sXFj/kcHsxPQDFm/Y6pqrNRwVVhblvrYzDamQwWyWPAxKkYdUn2F37SE7vafs95k57wDsHTxIuFq6c484bObPNyMoD8FICzD7gZuvYYMmgcERTF8GET+kaYIregrRfSTvv81rZGLMkr5g65G3Zc6G6RNAWc0uLefRlixAK2QiMXnbe3EhbuJmj8/8wC7CGT+7AgT0QS6LeWCafpGUC2zBUCxCZULhXEhexyZ0XHGgqjtqFGWRpiyIOD7YiDfWttxgX5UvxU3TT0U1W0hKGNh36nDpAQDp6sGTxOGQN7ZSOv244Hru91/DnOAhsfwFQdyZP+wOzK9sWHM7hEycP75fCWO+xDWBV8VNnk7uc7IY1KLijvJmpbwGt/wQN7RLpZTB7w5RMYCPyyQtvHLKweVxA+I49cOgGrNJDnPePP/bbWguWogQQ+J5DlvghnfMHzaKBdQC2GxYrAjdSrqJIS/JgFqVkMve8u57ZESRVHHZ4f8tTZfV1FKGDi6F5G5YL1Dr3OKNMRVICTAULRxOd+9UIP0cgeRl6nfQ8cQgkfLOKiZ6NZuufSqZZOoT4JSFAaQ1Yft1cLJUevJIEL9RoJ7vCDSmtdGObw5kRk5VbGdy8H0V0DsXlXzinKbnzJarLBhfakktSEsNBlRl0wM 41ZUpa/d 8o8aH4XjFF+5Ul5oVU68OHcJR1KnVY8VbX0BTpZyOX0ComV+/cC+VOeZg+W2oP+naSUz7otFDN/mny5BO5NAtQ8aZsnunAvBVK0ZejJsj6ntygin674r0hi+cAhT9aZHJk6F0Hpyejl469lDoyk7qfTUp1Uag8RIj7sDAYb9OBkF9TQDtkjiOoJ4oXUCMXs3Ldxe2rsAxbkZBtobSp9jh6A7XLXIw51mClCIZ2n5fPz74x0c= 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: List-Subscribe: List-Unsubscribe: On 22/07/2024 07:14, Baolin Wang wrote: > > > 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. OK, so to put it another way, swpout_* stats are required all orders in (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE_DEFAULT) if CONFIG_SHMEM is defined, else all orders in THP_ORDERS_ALL_ANON. Have I understood correctly? If so, I'll fix that in the next version.