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 E9A78C001B0 for ; Tue, 15 Aug 2023 23:34:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54B4F8D0019; Tue, 15 Aug 2023 19:34:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FB568D0001; Tue, 15 Aug 2023 19:34:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C2678D0019; Tue, 15 Aug 2023 19:34:01 -0400 (EDT) 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 2C8808D0001 for ; Tue, 15 Aug 2023 19:34:01 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EEDC11C92CC for ; Tue, 15 Aug 2023 23:34:00 +0000 (UTC) X-FDA: 81127944240.01.5491BE2 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf17.hostedemail.com (Postfix) with ESMTP id 23B4440014 for ; Tue, 15 Aug 2023 23:33:57 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Cw6ciT5y; spf=pass (imf17.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692142438; 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=LElZJhpduxEU4sWkxfM25FSwjJTb1QYIyUiD6unT77w=; b=ViBUxjOo550m0ugQrEI1F7VqntWa2SDGHdsVuSXRDoRkGKR/FcaAq/gTuPJ3iifak7v73l QxxZvf2/edVfzMYQbU5Me8X+HbhJnOtnx2IZhG7nbyCcH3XTqvIfCqjtF9vTiUxdsug7qU 6RJ2Z3+vUtTByT+rxrpKuuVfY4yw6BQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=Cw6ciT5y; spf=pass (imf17.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692142438; a=rsa-sha256; cv=none; b=oVyWjSY+FNVA31IW5aCdn/OK/Xs80R2AqMzppVlLv2UQWEiS0hgubnn7+vz54+dOQm2BDI tJtAHm2Z5MML3lnCNZ3ZakjVK0+hh+Qz3yhXVcRLCaemkBbN57mr1rwjW9JO8d2gqJQaYb QCVnqd97uRZjxUCCuMsHtOG/dAfYeWo= Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-9923833737eso786589866b.3 for ; Tue, 15 Aug 2023 16:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692142436; x=1692747236; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LElZJhpduxEU4sWkxfM25FSwjJTb1QYIyUiD6unT77w=; b=Cw6ciT5yRWFFnlG80NSuQLQ9+odQLFxshY152ZCSAUdtA1fGf2JpY4J274xDlsmGU2 t0XZy8PYHYAgqR8SoSAuRTZ50hmMpobcNaDsK/5xu39ncUlQrnhKXiwPKxzO5jWNKj0h Qd5MV/rkq3RyCzT8u18Kf9Adsmu+las7Hxs624oDR2kOuBXjBhIBVon7lqHZPWneTUsq iUbFjsBVhaRY9HhSUYLwwL+fydn5gnjKmeHgngWbQZ33hQWmARCuDOmsWL4ECEI5ficT cMWj2zhKR8Nrclq+EDNOiKcmJNODuR69koyuu1yEU5lrmFq2f1gGUbmJtGYdjSjJgplq WXYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692142436; x=1692747236; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LElZJhpduxEU4sWkxfM25FSwjJTb1QYIyUiD6unT77w=; b=HttBx82Ckiq3DXNOAzZL6RUZqEgJ2l/5nk1oD4XG65AfxJQPcUXsiW3b4xyZITuyMk bVC/LfdMUs3jK5BThJX3uVT6MEP+ChuCKpss8dlWm/b5tylJlavF27CTxgiNAaG5BaB2 6dVJi1bQJ+Ab+l+FT3uCEHGpVnCDUC345oDkMFXe4x2GaRtbrtCKILPb4h02B5Kp81Zz smKt6GwfOCGvNS9Pxbig++AxnyMiqeQNmuTtmNi+oL6zbRaNmBvh6KgvGlFr84mQHJp4 H2Gqsoias4x1CA1R9QVh5+4cQLaOUUROFJAgb/9CTaZGI3FnUk9k6yZRh7MFCiDkjI51 /XPQ== X-Gm-Message-State: AOJu0Yzn6H3+gwdo/H7YqIPg9jgWZCwGOznaqeItcoQutyHh3rzIRrky 47z8+EBjSKX7M4eHgDdMmp4abTwbol1dp8KWualYEg== X-Google-Smtp-Source: AGHT+IEH2OOpbmLlYO/bY180QT/KSJgeQbAK5EHqLAOJuZGYm9/LkyCpJFHFt3F0wFLVHMdCcDER1YCly9R8Nm3Hr7M= X-Received: by 2002:a17:906:5910:b0:99d:6b79:6ed1 with SMTP id h16-20020a170906591000b0099d6b796ed1mr101047ejq.55.1692142436432; Tue, 15 Aug 2023 16:33:56 -0700 (PDT) MIME-Version: 1.0 References: <20230815032645.1393700-1-willy@infradead.org> <20230815032645.1393700-9-willy@infradead.org> In-Reply-To: From: Yosry Ahmed Date: Tue, 15 Aug 2023 16:33:19 -0700 Message-ID: Subject: Re: [PATCH 8/9] mm: Rearrange page flags To: Matthew Wilcox Cc: Peter Xu , Andrew Morton , Jens Axboe , io-uring@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 23B4440014 X-Rspam-User: X-Stat-Signature: cz6o1egpjpzp118mocqig79mc7jpbfi6 X-Rspamd-Server: rspam01 X-HE-Tag: 1692142437-925733 X-HE-Meta: U2FsdGVkX19Br+TV4rFavC0XlyTRkqgVB2bW+8cLd+n1b4x5ZYrNa4OdMwfwy/C/oEuR08PSZTMRpA5v1UD9qpk5vsfn5UdJKHNQCRPXfeUbjWbbSjlf0hxJJBPKVibqWzQ0tkUSqlwqtGBkE5+aCtK0xFpXxKDAMOTDoL3Z4mlLsPfXlifBipTE0Tsnc9UtUq0kN4jtjW50WIBey+Ip+BGSaEzx8ONldFFuXOLZGI9eTgpTp3mFOVRsQvOphEIWkNnNd4KKKirbCPl7f+iqRz4YDIvM+d/zVxRIHNRVd68x9/UnKLHOSbut8dk0pzEqF3BRfnJrpTVvFCtD5uO3XtIj+e/8QU5XkLEXmrdOOfKxTY/UPlc926BCcrOSfNzYM4pYz36BTHqH/OHbE6LoKj5NgHtixzmUG2mFOESz8O0b55X67HgBI+EUqK64+9KEvyLQ0BzWjK7yc7LNM16GjKovlHLu6LW8uTFvHq5tczxlLUYlt3Lfcc2a45YctkLF9mE46eU/CoMJ0l8T6idt71ICUsGsIsaFJeEH3q3HyoowpCb9+sx8aevksKqMRNh+6PahROzf6QgrfxtIxHTAsn+OF1j1jUeqFcQRfLREgXCWMexCEppbpis3q/vYsiIRvq3IZAgVf8ZIjON9iXK1o6ZiGFTZoKhM6EGKsMU7RupC2bK7l4LnhFc943z4+p4dYKztdXM9M0p6aSCq3IBRDdPh30afHmDHzDPoD5jbG7440LECrSJiMzpkvsUvKa8rjgL61WImS7cCppnUKtQrhNRM3fj+oxZvUmvNKf4Gyio0H2Nw4Df39TDGIbCMl/oeFXRGQwaHwlMGcrB4URtdHdBH88wPSDkeqMiM7FjBdriy92ciGgVQQ6PvJ8imKr4WcFT7t3PJYWsuhYTMzs5HWx1iI8OYxNd3Fs8Utq8E2mV8qgNCv02+Uwu1Ahdf7UHebpGavX/S+v6HxOiSTOW W3iGgWOy pr1WovRoH9mMEhcIVn9ze3KIeZ5OwB67ycLHQqBCeF4/0fizO+FdHpgUKT8Ju7kFl2wJg0zliE1E0w95A0o7c7sf7oeheG6+hEvP/Vj9JSCiM+pB8/fN2eXUNOKFTNmQND8BUklMHl/QowuvHD/y2VBe1LyP7DI2MeN4tY/Ah77kvQlSSfsIunha/tSnHwnaHedoIWyavboGYNBZM4+5B7I8gYbPMzPy003j5FsBX5sUxxhTR0+UYtDPpkp+QD+usOA0DELOwhquh340Y0ZOQVjFwjv90/pESe3E4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000841, 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 4:01=E2=80=AFPM Matthew Wilcox wrote: > > On Tue, Aug 15, 2023 at 03:31:42PM -0700, Yosry Ahmed wrote: > > On Tue, Aug 15, 2023 at 1:07=E2=80=AFPM 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) w= rote: > > > > > +++ 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 usef= ul. > > > 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 botto= m > > > byte of _flags_1. Because the order can never be greater than 63 (an= d > > > in practice I think the largest we're going to see is about 30 -- a 1= 6GB > > > hugetlb page on some architectures), we know that PG_head and PG_wait= ers > > > will be clear, so we can write (folio->_flags_1 & 0xff) and the compi= ler > > > 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 wit= h > > > PG_head set (which can happen with the vmemmmap optimisation, but eug= h). > > > And we don't want to move it any higher because then we'll have a fla= g > > > 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 int= o 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. I should have done the math :) Never say never though :)