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 1E274C4332F for ; Wed, 8 Nov 2023 02:02:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83C418D0094; Tue, 7 Nov 2023 21:02:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EC6E8D008C; Tue, 7 Nov 2023 21:02:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68D858D0094; Tue, 7 Nov 2023 21:02:13 -0500 (EST) 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 56A918D008C for ; Tue, 7 Nov 2023 21:02:13 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2E4E81A0B2B for ; Wed, 8 Nov 2023 02:02:13 +0000 (UTC) X-FDA: 81433136946.06.2E349C3 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf06.hostedemail.com (Postfix) with ESMTP id A42DE180021 for ; Wed, 8 Nov 2023 02:02:09 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699408930; 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=oK1/C0JiVGJa3RMpBPZTYK5aSLJYiH6r4ZXuvSWe3YU=; b=hgnXC7ie/o+G7aRiFE96FMDSdNDmEx2Y+VXUl1Lh6jmwOk9Ds/5JCwM1dtQHBq3JBkDrMD RrCI3shXbpQUNohz3+geNLQ4RP+L3WRHwEJt6VGNMbqmVqyCQjM607CMgFGJx0dXZzvJ+X 7T7lp6p5jDcmF8YeYb9MRKtApDa4QX4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699408930; a=rsa-sha256; cv=none; b=IzrlILmx4pCUywOI4GyeDN82f4v14mgSAqRwvCMclOU1JbC/hXe4i4dGqrVHS+TTPwbF6l 7YDAr181uQT5WOhGxOYK+LuLnwmykJQUtkjPty4OrvYMkyT1KRIdLPFUwOWRRE1etWN+A6 EBygIKpaX6d5WWgUeb9rksucEXLyulA= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SQ7Xv5Rfyz1P80c; Wed, 8 Nov 2023 09:58:39 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 8 Nov 2023 10:01:19 +0800 Message-ID: Date: Wed, 8 Nov 2023 10:01:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] kpageflags: respect folio head-page flag placement Content-Language: en-US To: Gregory Price CC: Matthew Wilcox , Gregory Price , , , , , , References: <20231030180005.2046-1-gregory.price@memverge.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: A42DE180021 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: kdt5rwf3mohcqogiemmm6p7udio33iao X-HE-Tag: 1699408929-152240 X-HE-Meta: U2FsdGVkX1+/Ga43iZZ1xn/amvDRm5qhXH5yEDGUqSyTxdV0KOmDiYISg992bqDx4qI9Q1w1qlxQsiXPacHcRZIyX5W7YnA9SIkf2Q18CR6LmqAv2UVzG5zwhn3CHN0HSwMP9PV9sm0lmwNT3lg0EhltgHqBTQVVbgde+swTAvScz6GHbncAB+aWP6KEU6HcI+klxPnAA1834P9+8qjxXBTk1S8KjEfY+1xPCBN5915h7w/CAaVurub1+RAXijVJk25pfpGM/5jPfHIB4Aq/Aeb9Ix99MltwTUaLbCXjs+5lS7A9BCSaldyOci7Hm2uwjbAM3DNRV5Y1j09o8fybSQqII3nuoKrHKaD4dn/6sNYb2td2+iCVac5FnL6nqd0ZeIRNqwq7WOE5Bgg2YwOUEcQDTQzCV1sB5GBIT0TwkI+On9aP5jCozvVvOefOTnC2OSdYdqYuxsHe6LEu8qS3KG4S8O2onm4zytxcNnXUAimu14jgDdLI+eajYqqN/Na+t0jS2wPXVQGJc44WgB9nevosR7PNIErxSF+tsUOYcKDdd5R0yKWUxgzG4jVkWHeMsP7N0bgw+Rz8SgZbhc7HUH+e1Kv9PA30A2NfAgjPi+nNU9yCrYSWY2vyOoQz1lRL98VPK8tE8F7e3f4u4lqfapoxg26I/rMSb9zn43JNgzdjZDgPJwAQCYVNoWu+/fM01frlQAeUonaBh/3hZHOIWA5lwoJN9VMcSsnF4qAQ9ok5uDom92xCU4dBXLqX/pq0PRrGLnVNDGp7/i1UIxYvC5LphgxTpQDrQ1TtQ5IhBSpW36eukijfPjhiB2x7zlxgx5lI0mNQ0aKuRVnjNMiNs6ZEccJhK7jS7KSTS9SNC0N/Sc/0yeYYKu2nmK6L90k7/QwDHUXt4WngNf+AdeId3Ccj+2LdKZWFrxDzBXcqLlGMBqzTnZmHt7zRyOTftENZ4g1i9JazTspsvHXuP0Y EmEPAxyg Nj6Gs7XfmOedBERZ7sX7AZ76rFPJxwRI4cEDecAzYleqh5I4Xf97YDXsXVzD9jjqR1fSMtMYzTiv/LcxAlrkoq37cRGxMmiyGKgYKXJyK0dJ0mcAPaZ1dQ4yWoRHdhvk/OYp+1NVeYgg7IoZ72WueCLKK9HKAQwSBVCc8jNWt7pIIrCjGSdG8+/dMSGnLwuXMfmP+dEYfK4qDLks9ZLGoNeaiHg472ptw0hKvcOUpNH31J7j/AEAmxYJxGQj/t6g+D6BiUneVnG/mgmQAHhHepAKxnL6sa0kM6o/bf8Oz2EPDi2dtCWKm86YyvHLGYfwcmqRo8v9PDWbqmVp4e4s+tJlzIPjgtftwoFlE0vRlnacpguOy06LCZPFtjFwbL/9i2ruw 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 2023/11/7 23:34, Gregory Price wrote: > On Tue, Nov 07, 2023 at 09:03:53AM +0800, Kefeng Wang wrote: >> >> >> On 2023/10/31 12:34, Gregory Price wrote: >>> On Tue, Oct 31, 2023 at 09:13:44AM +0000, Matthew Wilcox wrote: >>>> On Mon, Oct 30, 2023 at 07:41:23PM -0400, Gregory Price wrote: >>>>> On Mon, Oct 30, 2023 at 11:22:18PM +0000, Matthew Wilcox wrote: >>>>>> On Mon, Oct 30, 2023 at 02:00:05PM -0400, Gregory Price wrote: >>>>>>> kpageflags reads page-flags directly from the page, even when the >>>>>>> respective flag is only updated on the headpage of a folio. >>>>>>> >>>>>>> Update bitchecks to use PAGEFLAG() interfaces to check folio for the >>>>>>> referenced, dirty, lru, active, and unevictable bits. >>>>>> >>>>>> But uptodate, writeback and reclaim (amongst others) are also defined >>>>>> only on the head page. >>>>>> >>>>> >>>>> Ah yes i was only looking at the things defined w/ PAGEFLAG defines in >>>>> page-flags.h. I'll give it full once over can collect them all, my bad. >>>>> >>>>> (also i forgot to update my commit message) >>>>> >>>>> Quick question here since i have your attention: any recommendation on >>>>> what to do for ONLY_HEAD flags? If the provided page is not the head, >>>>> should the flag report 0... or whatever the head says? >>>> >>>> Thinking about it some more, really almost all flags are per-folio, not >>>> per-page. The only exceptions are HWPoison and AnonExclusive. So >>>> probably the right way to do this is to make k = folio->flags, and >>>> then just change a few places rather than changing all the places that >>>> test 'k'. >>> >>> Funny enough that's what i originally did but was confident it was >>> correct so walked it back. I'll take another crack at it. >> >> Hi Gregory, any update? >> I changed stable_page_flags[1] when try to remove page idle wrapper, >> Matthew pointed it will conflict with this, I could redo my patch >> based on your new version:) >> >> [1]https://lore.kernel.org/linux-mm/20231103072906.2000381-5-wangkefeng.wang@huawei.com/ >> >> Thanks. > > looks like we were noticing the same thing. I haven't done any further > work, got caught up in another project. Yes, I see your "Node Weights and Weighted Interleave", this is an interesting topic, we need some easy and efficient way to use tiered memory. > > Matthew last pointed out: > > "probably the right way to do this is to make k = folio->flags, and then > just change a few places rather than changing all the places that test > 'k'." > > https://lore.kernel.org/linux-mm/ZUDFSEvpxxoGWmdG@casper.infradead.org/ > > I took a quick look, and the only thing I'm not confident about is that > some flags are stored in the head page, and some are stored on the > second page. > > /* Which page is the flag stored in */ > #define FOLIO_PF_ANY 0 > #define FOLIO_PF_HEAD 0 > #define FOLIO_PF_ONLY_HEAD 0 > #define FOLIO_PF_NO_TAIL 0 > #define FOLIO_PF_NO_COMPOUND 0 > #define FOLIO_PF_SECOND 1 > > There's only a handful, so yeah the best way is probably to go ahead and > swap k = page->flags for k = *folio_flags(folio, 0) and then handle the > couple of outliars. If you don't mind, I maybe try to convert it in my changes. Thanks. > > ~Gregory