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 EFA36C30653 for ; Fri, 5 Jul 2024 03:01:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 722C56B009A; Thu, 4 Jul 2024 23:01:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D0AC6B009B; Thu, 4 Jul 2024 23:01:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BFFC6B009C; Thu, 4 Jul 2024 23:01:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4465C6B009A for ; Thu, 4 Jul 2024 23:01:20 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B1C5DA44A5 for ; Fri, 5 Jul 2024 03:01:19 +0000 (UTC) X-FDA: 82304197878.28.0D39E65 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by imf06.hostedemail.com (Postfix) with ESMTP id 70F0918000E for ; Fri, 5 Jul 2024 03:01:17 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=R+eDdP3D; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf06.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.110 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=1720148449; 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=RXHUr7dIEjsbQruRykvzvbQCHWUjTYhMyKV4za3Jfiw=; b=SeDntpjHt3W248bZ//yqYdrnYmW+98xjmXVpv7gkVEjDpAaJa+EH19nMLZDIrYv6UnOk7z pPAVFARXjnF5fNgge2JTtp9xY+5tx3xFCW1U2F288okZ63N7zZLc6gbaSKQ9qzRZ1KZkoE WvvOwUophyroSjlKiCtG5lkK4xCizmE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720148449; a=rsa-sha256; cv=none; b=Qq/8k+iCdlhssLZTzBv+wZ2GExpOa/ZVxp3HwEs93ZI1qmm87AVWPRdsR6AuX+SL5an7By aRx7V/2ATTKi2kabPqN0C2Jg4IZIaT7nAqLhMPgCrOqcAR98M+4PN7pNOWlMYgiw4uLlYH NeRyfULmJG4/+VJEpGis1/FIf6BysKU= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=R+eDdP3D; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf06.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1720148474; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=RXHUr7dIEjsbQruRykvzvbQCHWUjTYhMyKV4za3Jfiw=; b=R+eDdP3DAc7LhtfsB8hgGws+ruccWiJVX6vZzNgs39tICAAfFe1kxhUsd5F3VC/YAhQ0mclpmx7qDEQE05UefMmYV9xtRqS2sClSl9yJ5H9M1GvR2BBzrUU1RfnoOlCweE49O2ldWE+A8Bjqs+SV1sPFaYgGb8zTpEabqcF5+ms= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032014031;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0W9tBVtX_1720148471; Received: from 30.97.56.65(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W9tBVtX_1720148471) by smtp.aliyun-inc.com; Fri, 05 Jul 2024 11:01:13 +0800 Message-ID: <076550c4-0e8a-4344-9f8a-31ae9e1051b5@linux.alibaba.com> Date: Fri, 5 Jul 2024 11:01:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 4/6] mm: shmem: add mTHP support for anonymous shmem To: Bang Li , Ryan Roberts , akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, ying.huang@intel.com, 21cnbao@gmail.com, shy828301@gmail.com, ziy@nvidia.com, ioworker0@gmail.com, da.gomez@samsung.com, p.raghav@samsung.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <65796c1e72e51e15f3410195b5c2d5b6c160d411.1718090413.git.baolin.wang@linux.alibaba.com> <65c37315-2741-481f-b433-cec35ef1af35@arm.com> <475332ea-a80b-421c-855e-a663d1d5bfc7@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 70F0918000E X-Stat-Signature: 3cs9693gat9q1ctnfhr3foe8d8rn69qu X-Rspam-User: X-HE-Tag: 1720148477-512936 X-HE-Meta: U2FsdGVkX19pZ5oQYbwq2eHgXLnGs3jkopBKKo6TUZoD8oHF93N4V4166JX6Nct18iulTCdrAIRP572YnvudiSS+Ms0QxpUGeyhwnpPSbmyWXNxhV5a87vz0Yy4+dOu08br7sYjnteg0C1zRkBhlvKgeFqFRWT6BZt4gOAezUW5GsH3XWpBCUkrg577uZ5Ux7v5UC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LOt57RSuzr1KILRVSkqDKKLsxuP+dUrJr2pW2UBvNJFG8eyDh2hyqBxcwkcLv+h7C+9xbCxrRIJAB2oYnJgFMVD0aP+2oY5hDQ+xysNIAnHyt68I1fbLQGn1ESS4M4s9R4tiaZQ38HoBsJpmXLm8goyTEJkdchwJ5IduOeEsApLBPp7Iac7Gb5hEsZj+CMIowhx6 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/4 22:46, Bang Li wrote: > Hi Bao lin, > > On 2024/7/4 19:15, Baolin Wang wrote: >> >>>> + >>>> +    /* >>>> +     * Only allow inherit orders if the top-level value is 'force', >>>> which >>>> +     * means non-PMD sized THP can not override 'huge' mount option >>>> now. >>>> +     */ >>>> +    if (shmem_huge == SHMEM_HUGE_FORCE) >>>> +        return READ_ONCE(huge_shmem_orders_inherit); >>> >>> I vaguely recall that we originally discussed that trying to set >>> 'force' on the >>> top level control while any per-size controls were set to 'inherit' >>> would be an >>> error, and trying to set 'force' on any per-size control except the >>> PMD-size >>> would be an error? >> >> Right. >> >>> I don't really understand this logic. Shouldn't we just be looking at >>> the >>> per-size control settings (or the top-level control as a proxy for every >>> per-size control that has 'inherit' set)? >> >> ‘force’ will apply the huge orders for anon shmem and tmpfs, so now we >> only allow pmd-mapped THP to be forced. We should not look at per-size >> control settings for tmpfs now (mTHP for tmpfs will be discussed in >> future). >> >>> >>> Then for tmpfs, which doesn't support non-PMD-sizes yet, we just >>> always use the >>> PMD-size control for decisions. >>> >>> I'm also really struggling with the concept of shmem_is_huge() >>> existing along >>> side shmem_allowable_huge_orders(). Surely this needs to all be >>> refactored into >>> shmem_allowable_huge_orders()? >> >> I understood. But now they serve different purposes: shmem_is_huge() >> will be used to check the huge orders for the top level, for *tmpfs* >> and anon shmem; whereas shmem_allowable_huge_orders() will only be >> used to check the per-size huge orders for anon shmem (excluding tmpfs >> now). However, as I plan to add mTHP support for tmpfs, I think we can >> perform some cleanups. > > Please count me in, I'd be happy to contribute to the cleanup and > enhancement > process if I can. Good. If you have time, I think you can look at the shmem khugepaged issue from the previous discussion [1], which I don't have time to look at now. " (3) khugepaged khugepaged needs to handle larger folios properly as well. Until fixed, using smaller THP sizes as fallback might prohibit collapsing a PMD-sized THP later. But really, khugepaged needs to be fixed to handle that. " [1] https://lore.kernel.org/all/f1783ff0-65bd-4b2b-8952-52b6822a0835@redhat.com/T/#u