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 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D49D1C4363D for ; Fri, 25 Sep 2020 15:00:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C04E320715 for ; Fri, 25 Sep 2020 15:00:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="N4tLub0y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C04E320715 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3DD5590000A; Fri, 25 Sep 2020 11:00:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 365E9900006; Fri, 25 Sep 2020 11:00:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2554690000A; Fri, 25 Sep 2020 11:00:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 0E842900006 for ; Fri, 25 Sep 2020 11:00:56 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 81C203654 for ; Fri, 25 Sep 2020 15:00:55 +0000 (UTC) X-FDA: 77301896070.26.balls83_4f0f1fd27168 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 279DD1804A305 for ; Fri, 25 Sep 2020 15:00:54 +0000 (UTC) X-HE-Tag: balls83_4f0f1fd27168 X-Filterd-Recvd-Size: 2858 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Sep 2020 15:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=zuusnAG44HD1n2J9Niwz70ELSrBC4ONVkjgnl/QWy/0=; b=N4tLub0yK62NBSp4TaO9bV/pz3 1hWWiL35voLWId2PGhy+qqRwhS7xxLQ84uOL9Kjd4kiWogLL/scxZ89BY9BnT1l2rif7VDUI57RDF 0mj6R1K8OCsuQHuqaXPdq2SdbrgtNLXYkH7ATa4ICe/0s7lcP6hLmRrohPomUbcUlRdXBi3AACZAP w30A7BTWMG0ofsrV+3Tdy2rWMvIEH/dRT3FQmQ7B84nQcxM8EV4BZrpzAkO3QyxfI1Y/KbGGGEU1W OtCP+z7VhRnkgYqTCkDeODRazHMkJ0xsGlcS7PEr3Yefe38fvVHnTqJYJHJnKzebt9zQygLTk8Gr9 E7OIrJTg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLpDO-0007NB-Tm for linux-mm@kvack.org; Fri, 25 Sep 2020 15:00:51 +0000 Date: Fri, 25 Sep 2020 16:00:50 +0100 From: Matthew Wilcox To: linux-mm@kvack.org Subject: PageLRU and the other flags Message-ID: <20200925150050.GF32101@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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: I'm not quite familiar with this side of the MM yet, but it seems to me like we're encoding four page states in three bits: - !PageLRU (not an LRU page) - PageLRU (on the inactive list) - PageLRU + PageActive (on the active list) - PageLRU + PageUnevictable (on the unevictable list) Can we neaten this up into two bits? - 00 (not an LRU page) - 01 (active list) - 10 (inactive list) - 11 (unevictable) People who free up page flags are always popular, right? I don't think the missing combos are used: !LRU + Active !LRU + Active + Unevictable !LRU + Unevictable LRU + Active + Unevictable It seems fairly straightforward to add these macros: bool PageLRU(struct page *page) { page->flags & PAGE_FLAGS_LRU_MASK; } bool PageActive(struct page *page) { page->flags & PAGE_FLAGS_LRU_MASK == PAGE_FLAGS_ACTIVE; } bool PageInactive(struct page *page) { page->flags & PAGE_FLAGS_LRU_MASK == PAGE_FLAGS_INACTIVE; } bool PageUnevictable(struct page *page) { page->flags & PAGE_FLAGS_LRU_MASK == PAGE_FLAGS_UNEVICTABLE; } SetPageActive seems a little more tricky to do atomically. A cmpxchg() loop, perhaps? If we changed the API to be PageUnevictableToActive(page) then it's an atomic subtraction / addition (although it's now twelve macro instead of six Set/Clear for three bits). Then I'm not sure how to do TestClearPageActive(). Maybe TryPageActiveToInactive()? That'd be another twelve macros if all those state transitions are possible.