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 7347BC433FE for ; Wed, 16 Nov 2022 09:15:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E45B6B0071; Wed, 16 Nov 2022 04:15:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 893236B0072; Wed, 16 Nov 2022 04:15:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 733D48E0001; Wed, 16 Nov 2022 04:15:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 610396B0071 for ; Wed, 16 Nov 2022 04:15:56 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1FC25AB9EA for ; Wed, 16 Nov 2022 09:15:56 +0000 (UTC) X-FDA: 80138748312.28.7EDBC8D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id BFB358000A for ; Wed, 16 Nov 2022 09:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668590154; h=from:from: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=lXB7geeDOHGl0xlPBQdCp9G9AIuT+xoszozZAW+zE8Q=; b=hA9KP2qeSt6g2lRo2lKMGDI3JYiTCPet5HYl0/lawtAt2SLHknXDft6CginJZBJxqXdRVF L2dj0WyDV6ebAfkzYq93Lurvburt6QO4TE20/CsyI6wcFKgChoaz2P3X9qiXh3JT5JjGVt HlZmDq33qk2nmy55GIxQJoCf5ZGe+PY= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-542-uM8A1o9xO9u7V3xKE9jS0A-1; Wed, 16 Nov 2022 04:15:52 -0500 X-MC-Unique: uM8A1o9xO9u7V3xKE9jS0A-1 Received: by mail-wr1-f72.google.com with SMTP id n13-20020adf8b0d000000b0023658a75751so3521985wra.23 for ; Wed, 16 Nov 2022 01:15:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lXB7geeDOHGl0xlPBQdCp9G9AIuT+xoszozZAW+zE8Q=; b=akQDRSuFfO1+WeVeULQ0yKDqcOPCEzZBCEdognosCmWoC+QahME9mE6/A6R7wWNfi6 gaPFaq1mS31XOZOz1pkr+Dg28mK5PxQjzNaPnXqAX7PklulvBS8USmceT1UMoC7ygWyL LFu40Vk4HCBU6USfzk0LA5ohldMRzrxjZ42o8VlaGTOGNFOC/94OQCZa7dpVBfUY61n+ KUc9tHs+8SHSAC5iQBhp27eVSfH6rYGsBLwmKLHOheL/UJ1VaLx2/CwQPJkV8PytF4PV VwSajLiQEgtvBo84TuBMFTl73ddbw5bQKgKZEa8S98IIF/MFm9hsuCI3eEn47V22mtAe 4sog== X-Gm-Message-State: ANoB5pndb6Ohzphhz9gEzS6aVyB684K8uE2QsxnuBcm1WlDPI1PCBFGN Ie8aZ67ilGYqHgb3X95qw/ZM+PawfN4NmIIy9GfqTLIbvGTzArJel+Xsyzwyie9MrTQPJ5BZBoP E1fYJG+Frqfo= X-Received: by 2002:adf:ba8a:0:b0:241:a825:205c with SMTP id p10-20020adfba8a000000b00241a825205cmr723882wrg.40.1668590151410; Wed, 16 Nov 2022 01:15:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf5q1YiQuRZuDh0m/3hidhum4BE2NmI2J9RofCm2nmoGqmv7HNMCAG+OXViUb83JQKL/H5aWnA== X-Received: by 2002:adf:ba8a:0:b0:241:a825:205c with SMTP id p10-20020adfba8a000000b00241a825205cmr723867wrg.40.1668590151028; Wed, 16 Nov 2022 01:15:51 -0800 (PST) Received: from ?IPV6:2003:cb:c704:9f00:a98d:4026:7c44:40fd? (p200300cbc7049f00a98d40267c4440fd.dip0.t-ipconnect.de. [2003:cb:c704:9f00:a98d:4026:7c44:40fd]) by smtp.gmail.com with ESMTPSA id n126-20020a1c2784000000b003b95ed78275sm1350756wmn.20.2022.11.16.01.15.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Nov 2022 01:15:50 -0800 (PST) Message-ID: Date: Wed, 16 Nov 2022 10:15:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH 1/4] mm: introduce 'encoded' page pointers with embedded extra bits To: Linus Torvalds , Hugh Dickins , Johannes Weiner , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Gordeev References: <20221109203051.1835763-1-torvalds@linux-foundation.org> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20221109203051.1835763-1-torvalds@linux-foundation.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668590155; a=rsa-sha256; cv=none; b=s5jUKCu4Al/G7s9UPogDdVu3JFNv8JcGNnz72aD7JSlZUqnKSylU4eTy1BRrmzahmJChzA muDy9O0VTgtz2ccq2Y6WrcUnTtPfhYlzyJUaYPlmE9yTh7ihj34XzXebkuCoC9EP46WFCZ SfHLF9xElzLoEIGKkg+ZEyiM+vDvi04= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hA9KP2qe; spf=pass (imf02.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668590155; 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=lXB7geeDOHGl0xlPBQdCp9G9AIuT+xoszozZAW+zE8Q=; b=wNMwYotCh5pASoqEDaEYRSYNrntawqtUTWwqe+iOrkGpXuBDpLn8ita3qW81pr307YqaGT HCteFkF5V5nZJv3o9KBC0TAUecdtNEZOBd6ZKk5uAVBHH14Me/F93/QO77tjCf6Zj8KhEP ZnGlFEZMNgRABGZOLTCs9cz3lCUYHW4= X-Rspam-User: X-Stat-Signature: 5dneign8uwwz1cs45sf79px6645w8nis X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BFB358000A Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hA9KP2qe; spf=pass (imf02.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1668590154-504570 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 09.11.22 21:30, Linus Torvalds wrote: > We already have this notion in parts of the MM code (see the mlock code > with the LRU_PAGE and NEW_PAGE bits), but I'm going to introduce a new > case, and I refuse to do the same thing we've done before where we just > put bits in the raw pointer and say it's still a normal pointer. > > So this introduces a 'struct encoded_page' pointer that cannot be used > for anything else than to encode a real page pointer and a couple of > extra bits in the low bits. That way the compiler can trivially track > the state of the pointer and you just explicitly encode and decode the > extra bits. > > Note that this makes the alignment of 'struct page' explicit even for > the case where CONFIG_HAVE_ALIGNED_STRUCT_PAGE is not set. That is > entirely redundant in almost all cases, since the page structure already > contains several word-sized entries. > > However, on m68k, the alignment of even 32-bit data is just 16 bits, and > as such in theory the alignment of 'struct page' could be too. So let's > just make it very very explicit that the alignment needs to be at least > 32 bits, giving us a guarantee of two unused low bits in the pointer. > > Now, in practice, our page struct array is aligned much more than that > anyway, even on m68k, and our existing code in mm/mlock.c obviously > already depended on that. But since the whole point of this change is > to be careful about the type system when hiding extra bits in the > pointer, let's also be explicit about the assumptions we make. > > NOTE! This is being very careful in another way too: it has a build-time > assertion that the 'flags' added to the page pointer actually fit in the > two bits. That means that this helper must be inlined, and can only be > used in contexts where the compiler can statically determine that the > value fits in the available bits. > > Link: https://lore.kernel.org/all/Y2tKixpO4RO6DgW5@tuxmaker.boeblingen.de.ibm.com/ > Cc: Alexander Gordeev > Acked-by: Johannes Weiner > Acked-by: Hugh Dickins > Signed-off-by: Linus Torvalds Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb