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 11E90C2BD09 for ; Mon, 1 Jul 2024 08:46:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8350A6B009F; Mon, 1 Jul 2024 04:46:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 746966B00A0; Mon, 1 Jul 2024 04:46:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F0BE6B00A1; Mon, 1 Jul 2024 04:46:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3F6F36B009F for ; Mon, 1 Jul 2024 04:46:56 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EA591819CD for ; Mon, 1 Jul 2024 08:46:55 +0000 (UTC) X-FDA: 82290553590.17.2E098E6 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf26.hostedemail.com (Postfix) with ESMTP id A6B4E140006 for ; Mon, 1 Jul 2024 08:46:51 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=Ix6nHoS+; spf=pass (imf26.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719823597; 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=Sw5IgswMEuJV2XoSVcM0OJziGgFmvuhn48aAmj906Do=; b=BRUhwH62ocOEwtzB11l2/jXh2fXOu9uRYK9S1TTOyk/ssatk+axlBwyBPIkTAAv6aVOAwN 9lL04C++uVn2ATY5tH9zfD+Df7mRyuy8Ttm9WA8IjirufjywbLvEcJp0gg1+xgVhwu2Ge6 mIMvaspxDXg5WsUIjzGiw4AhRTmtB0o= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=Ix6nHoS+; spf=pass (imf26.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719823597; a=rsa-sha256; cv=none; b=yfDZp7tEi25FHPq+TbNNS1STwBtFoZu9/35pNjB6AplOKaqAlqoJN1Z8X0EwW5UnRshO4J cgW87qw/8sz2BFxwfprZYGqme8vBUYoLW1ZAHyRpBRZRRLG8vpnXQejQ4693Ncy4uswfYb lsS3KlBxuEZKNrh7V0VQ31XexMlNuNI= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1719823607; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=Sw5IgswMEuJV2XoSVcM0OJziGgFmvuhn48aAmj906Do=; b=Ix6nHoS+Yt/Ssxt5wvbcrOJgbP/JwJUVmamsHAcUP4iQwh4yBEStscgU3t+2UQqwWffYLiXJRGJWKBZ+TUAlx3pbbDQxzDV8Byaze32cQg28oe0EdHoXuRRuSrSOUrbTOQScsvYYsRjGmZ9j63/Zy8cgh0QLIbza1tAQCJ20IRs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067113;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0W9c7l2Y_1719823605; Received: from 30.97.56.67(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W9c7l2Y_1719823605) by smtp.aliyun-inc.com; Mon, 01 Jul 2024 16:46:46 +0800 Message-ID: <03acea8b-b0d9-403f-8dc8-1f32ee02153e@linux.alibaba.com> Date: Mon, 1 Jul 2024 16:46:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] support "THPeligible" semantics for mTHP with anonymous shmem To: Ryan Roberts , Bang Li , hughd@google.com, akpm@linux-foundation.org Cc: david@redhat.com, wangkefeng.wang@huawei.com, ziy@nvidia.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20240628104926.34209-1-libang.li@antgroup.com> <4b38db15-0716-4ffb-a38b-bd6250eb93da@arm.com> <4d54880e-03f4-460a-94b9-e21b8ad13119@linux.alibaba.com> <516aa6b3-617c-4642-b12b-0c5f5b33d1c9@arm.com> From: Baolin Wang In-Reply-To: <516aa6b3-617c-4642-b12b-0c5f5b33d1c9@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Stat-Signature: zhi9y1ej8wyq1efj3sicmj7nb1pkncu5 X-Rspam-User: X-Rspamd-Queue-Id: A6B4E140006 X-Rspamd-Server: rspam02 X-HE-Tag: 1719823611-78014 X-HE-Meta: U2FsdGVkX1+BG1gjSi4Q/YauAe99RXSZPWUykPIEPpsp8pNN08Yhr0S1q5C8AqgFlqnvfTgjq8ng2RcwTbr4qPXc1Y2j4mmP2lIztZlzYE95ZfS5JVFPlxMMlw/d8c9At2QMch4EfFt1Z1MtqPeW0AfXX1mAD6cRumgXo4rz2Njhl+0qSz9+s/jrEEd0AsDYLSDjiUttiI3ECDqhyNQjWtMqSW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7CdApnkAZ4V8qi75WDdj89cxIn0AjRtuwbXAl1C2bz98tDi6JTUsdrcVtoWeED+UTQgVeilRUhy8TWONQP3nN0/ 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 2024/7/1 16:40, Ryan Roberts wrote: > On 01/07/2024 09:33, Baolin Wang wrote: >> >> >> On 2024/7/1 15:55, Ryan Roberts wrote: >>> On 28/06/2024 11:49, Bang Li wrote: >>>> After the commit 7fb1b252afb5 ("mm: shmem: add mTHP support for >>>> anonymous shmem"), we can configure different policies through >>>> the multi-size THP sysfs interface for anonymous shmem. But >>>> currently "THPeligible" indicates only whether the mapping is >>>> eligible for allocating THP-pages as well as the THP is PMD >>>> mappable or not for anonymous shmem, we need to support semantics >>>> for mTHP with anonymous shmem similar to those for mTHP with >>>> anonymous memory. >>>> >>>> Signed-off-by: Bang Li >>>> --- >>>>   fs/proc/task_mmu.c      | 10 +++++++--- >>>>   include/linux/huge_mm.h | 11 +++++++++++ >>>>   mm/shmem.c              |  9 +-------- >>>>   3 files changed, 19 insertions(+), 11 deletions(-) >>>> >>>> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c >>>> index 93fb2c61b154..09b5db356886 100644 >>>> --- a/fs/proc/task_mmu.c >>>> +++ b/fs/proc/task_mmu.c >>>> @@ -870,6 +870,7 @@ static int show_smap(struct seq_file *m, void *v) >>>>   { >>>>       struct vm_area_struct *vma = v; >>>>       struct mem_size_stats mss = {}; >>>> +    bool thp_eligible; >>>>         smap_gather_stats(vma, &mss, 0); >>>>   @@ -882,9 +883,12 @@ static int show_smap(struct seq_file *m, void *v) >>>>         __show_smap(m, &mss, false); >>>>   -    seq_printf(m, "THPeligible:    %8u\n", >>>> -           !!thp_vma_allowable_orders(vma, vma->vm_flags, >>>> -               TVA_SMAPS | TVA_ENFORCE_SYSFS, THP_ORDERS_ALL)); >>>> +    thp_eligible = !!thp_vma_allowable_orders(vma, vma->vm_flags, >>>> +                        TVA_SMAPS | TVA_ENFORCE_SYSFS, THP_ORDERS_ALL); >>>> +    if (vma_is_anon_shmem(vma)) >>>> +        thp_eligible = !!shmem_allowable_huge_orders(file_inode(vma->vm_file), >>>> +                            vma, vma->vm_pgoff, thp_eligible); >>> >>> Afraid I haven't been following the shmem mTHP support work as much as I would >>> have liked, but is there a reason why we need a separate function for shmem? >> >> Since shmem_allowable_huge_orders() only uses shmem specific logic to determine >> if huge orders are allowable, there is no need to complicate the >> thp_vma_allowable_orders() function by adding more shmem related logic, making >> it more bloated. In my view, providing a dedicated helper >> shmem_allowable_huge_orders(), specifically for shmem, simplifies the logic. > > My point was really that a single interface (thp_vma_allowable_orders) should be > used to get this information. I have no strong opinon on how the implementation > of that interface looks. What you suggest below seems perfectly reasonable to me. > >> >> IIUC, I agree with David's suggestion that the shmem_allowable_huge_orders() >> helper function could be used in thp_vma_allowable_orders() to support shmem >> mTHP. Something like: > > I hadn't seen David's suggestion until after I sent my mail. But I think we are > both suggesting the same thing. OK. Great :)