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 708F8C001DF for ; Tue, 15 Aug 2023 23:01:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA8DD940035; Tue, 15 Aug 2023 19:01:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5A4B8D0001; Tue, 15 Aug 2023 19:01:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2144940035; Tue, 15 Aug 2023 19:01:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BFA708D0001 for ; Tue, 15 Aug 2023 19:01:16 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8CC5A80CC3 for ; Tue, 15 Aug 2023 23:01:16 +0000 (UTC) X-FDA: 81127861752.10.7D332A8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP id 18797C002F for ; Tue, 15 Aug 2023 23:01:13 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Uq6gvG3V; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692140474; 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=j4qmcEFXn/HEwzzgmOFjWOT+QdvX9TIUsfVg64W1WDE=; b=HT1bNCR/GizF5VttdzXIuAECP0s8IX5A3uJg9IFx8dFMW1GaISOLgGb5w8sH8gq3KSs5da iS8fSULU6cU4TGVRd+JJIqHifPP2gUiSRg/ngchLBzJdkqHqTEoWr1hYF0Z/vTm/wUAKZe OnPRvibKnElfm47BedL3qCXSTXmDCBk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692140474; a=rsa-sha256; cv=none; b=0g44qJGYuEVaUisHD1qaBNEaz5NgdAbjS/Edh/W+LEyQtNuh2qKuwx36aHmRiNEW3POZwg nMwWXGK01fHYUUJG9E1kQ+m4TYo9+tqbmPahkWwO+z4sO97VlvSWR+rOqZSR881SEeln64 MF2yKPCY5gxippyRbgzi4uB470HcHvU= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Uq6gvG3V; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=j4qmcEFXn/HEwzzgmOFjWOT+QdvX9TIUsfVg64W1WDE=; b=Uq6gvG3VyCgwcrY/X4VzU0IJuT wyTXYwGqZf7L/af+6LEuugLRbuKvL18dFAscfi5kTzSH/9FJ76WNRtTPntZfvCoI5hmDXGwoj2OLP 5TkP4mOYtgXXpKMJNJJ3gre2/6ztaLJxjjDtF8+lrRGlhqNIQUWgGJMlKiNOAHKPUhmSY0JOzN5sH 3Y06pyE8o+Ddn9UzLUWHuiCaM6M/ZxR0fxYz0KUkrf+3ylpw9hkHJ4Drf834Z3mCov10Ps0HFFMMd miCxQGqTgmMbSYIBz1510WLQlSxiAPE0ct2Z2T9Bn5E/P/evhZrZ+yxEUiOJcKSsfbSV8aZZAPYhg UjuQo7mg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qW32C-00B1sa-8f; Tue, 15 Aug 2023 23:01:08 +0000 Date: Wed, 16 Aug 2023 00:01:08 +0100 From: Matthew Wilcox To: Yosry Ahmed Cc: Peter Xu , Andrew Morton , Jens Axboe , io-uring@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 8/9] mm: Rearrange page flags Message-ID: References: <20230815032645.1393700-1-willy@infradead.org> <20230815032645.1393700-9-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: 18797C002F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qsg79gdcctgx3497m8539djngmitz98d X-HE-Tag: 1692140473-232878 X-HE-Meta: U2FsdGVkX1+OZnXpErYFX5hiFeJmBoRnw0uCGwyMkWmOpMmQvSGIP0YngFe/AcAarH9xA8km8JzP1c+5xHfhvJrdVjuoh5nPY0pLeD1dwardW5q4qLfTUSoEraUqmlRYl/+vv06Li+l4N5XnkC48+q0H8lSfOOsxsldWSZKC+MwRHh63uWqwO3to0psO/XBW/3+xhRWxv3kuufSV9hdi2my6qfH9JIzS3gExRkGG/n5OiyJKgqWn8ZEDK3Q0K9zCc8DIc8KrQiH98M8qDcqrUlegCehHHGKjaN73+NYFeE5dIqHdm1nMWrJZVLI0keQAW7dfwh8BCfgZXAxhlsQFmkmYvv02IOz2pJNx8G4WPyt26VMYF+8JzfnnGSh5xG84y4C0AOWIHisElGeqFIGdM+1nmsOjmQ3aSqVj3V7PTS28/CmrY4s2s2ji8PEDD4Xie2DJjpMwBeS3Q+4qTLookDj2Yb1o79dUsNfLjypQF9nCYgHYBORmyn300SWWw7+OMNP1e4bU02XeyGu8x0NsryKjlxiyiIRMKU81WJPGAP0MEFw5J5Lf3Beb1vjZBNt4rjn+nv+0QG/GjlCqhZ/+Eeu0DxH6xNu74He1IU9y5JqgBLfWB6S7GRwOxwVgE6F5CniZDRISWQ8g91ke+Qw7NZenoeMjM3la0jUCbWdwLuwHrXO4YMNGT8bOsHUgLeWpAMKv9/QmhwlHjBSmmDYCZNYvUayUfq9L+pY7x0qHDOGn7ZBC1DKvbJ39RPvZ4PBKrfh/+vYoNo9EPRKV7OY/G/FAsN7dcpsX7JnWlHiiGgi8d6KpCN/0j2T5blC0Xx0y0IDSoFett/xtYVF4oNqJw1OwcEvUxj/rMN6gp73n3dYB5MXGaDAXI0+tFYK1U3oczyne5Vdfgpa7SZ9FIAdroZO7RL4tk1I5iVj4Hcrr/7YqJ1tWvgf7OP/X8IhMxf82zG1jiwSfn3mQ1jg4cKI QhZ/cZFG 8cPSFmZz56RwDOBW3qEEOK8X/DQup9JnzUAoSg5JhkOv2Kpbs0RWL30HpzxXlc+HlEweGqvJg9lHtFd2uzUqG3rzrSdb71QqOmUQapaP4gYmmVhOE2g8uu6CBhKWeQgFytp4qcdhXxPxwyLvCA96XOCH/6MFaf+kcchGugtxbYSwHIHjA+Tsjy5V1qFhLR1txHn13 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: On Tue, Aug 15, 2023 at 03:31:42PM -0700, Yosry Ahmed wrote: > On Tue, Aug 15, 2023 at 1:07 PM Matthew Wilcox wrote: > > > > On Tue, Aug 15, 2023 at 03:24:16PM -0400, Peter Xu wrote: > > > On Tue, Aug 15, 2023 at 04:26:44AM +0100, Matthew Wilcox (Oracle) wrote: > > > > +++ b/include/linux/page-flags.h > > > > @@ -99,13 +99,15 @@ > > > > */ > > > > enum pageflags { > > > > PG_locked, /* Page is locked. Don't touch. */ > > > > + PG_writeback, /* Page is under writeback */ > > > > PG_referenced, > > > > PG_uptodate, > > > > PG_dirty, > > > > PG_lru, > > > > + PG_head, /* Must be in bit 6 */ > > > > > > Could there be some explanation on "must be in bit 6" here? > > > > Not on this line, no. You get 40-50 characters to say something useful. > > Happy to elaborate further in some other comment or in the commit log, > > but not on this line. > > > > The idea behind all of this is that _folio_order moves into the bottom > > byte of _flags_1. Because the order can never be greater than 63 (and > > in practice I think the largest we're going to see is about 30 -- a 16GB > > hugetlb page on some architectures), we know that PG_head and PG_waiters > > will be clear, so we can write (folio->_flags_1 & 0xff) and the compiler > > will just load a byte; it won't actually load the word and mask it. > > > > We can't move PG_head any lower, or we'll risk having a tail page with > > PG_head set (which can happen with the vmemmmap optimisation, but eugh). > > And we don't want to move it any higher because then we'll have a flag > > that cannot be reused in a tail page. Bit 6 is the perfect spot for it. > > Is there some compile time assertion that the order cannot overflow into bit 6? An order-64 folio on a machine with a 4kB page size would be 64 zettabytes. I intend to retire before we're managing memory in chunks that large.