Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp392658rwb; Wed, 16 Nov 2022 02:06:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hWqEm1zkJWSNc9uxhFudt0RUxLGHXwBb1KWkKEhmXjzOXLnv+WIPiBpzBfsZwliKnIMkP X-Received: by 2002:a17:90a:8681:b0:1fe:b9b:7d31 with SMTP id p1-20020a17090a868100b001fe0b9b7d31mr3061046pjn.152.1668593202669; Wed, 16 Nov 2022 02:06:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668593202; cv=none; d=google.com; s=arc-20160816; b=MIh5h+/v70r9Hl6Rjh70ik+GU/tuN3c8BtASowh3RZbAAq42dxNZM0Tr67ncI5b45m dfIweUwhX/y1XWhC+36nZj7Vqskvm/5sLBwUooiyVUOAjbjBoTGYKCZ4h7enZRCX2xra sazWC21cGxS2dUYfOWTyeSKb1++5P20SZXmRtkjd5TXYWeUCyg9iljEGL4TRcIofpxoV F7GPlGjhCPg655gL6m6eDgEgx71UmtaAaP77HDqlMJX49uRAAAcaM2F9a0mMLHMswLEB eesd/PCxvzt2vy8sx8VLKp3kfFsXte3T/4TB16mxhlBoOE8fKrKEs+U0Pyf+pY3YIVWW UHog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=lXB7geeDOHGl0xlPBQdCp9G9AIuT+xoszozZAW+zE8Q=; b=sZJQQVw5FWcH8b8xVwykLtiETabjHDnEJvSUYd3myYj2RWYQTA74L74S37Fgg9bxrT JkObMxcLLew7wIGtzAWtA+Eol4EzKNqiM3v81hbUWokQ6TukANxKAJ5KoNovGb2zWHog ev/trC732rLPRTKzOQxrN+0Nfl3DqdAjugrIAp/wDUhNAXK5cy9t1rJabqEpGq4EZCZA IZPk2uuoUW3Hal459qaoUc3CTGnl6G+2iESFc5ApLTiiXv0gN6bR1xPtc5ikX7fGclDb ftyZyv4AVtNQyvd4ZbX3JgviCRses/10/7n6LIJ4CPBZX6lXbiYufBjGb24VjTarDe0r yW4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fVDz5n9h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jh19-20020a170903329300b0018890a7e9b5si13011396plb.287.2022.11.16.02.06.28; Wed, 16 Nov 2022 02:06:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fVDz5n9h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232947AbiKPJRN (ORCPT + 91 others); Wed, 16 Nov 2022 04:17:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238176AbiKPJQw (ORCPT ); Wed, 16 Nov 2022 04:16:52 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7C5F63A4 for ; Wed, 16 Nov 2022 01:15:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668590155; 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=fVDz5n9h4FfwTD2VpYIKPhPIrtueu7p00eXLJ9uNHU+RvtsJ+X4l5VxDWinbh7zGzFb1UZ dBPuge7Io3mFUgd3mnZCa68LEZNTKl+ZfUf3t7NxHSIQ01PSFaAbU1mxOY1H2c8YJfADRq 8OYz9sQYybF4RJ6UK/66M3qONrF8Gqc= 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-642-dIuxcO3vOyWzUZUknMUIHw-1; Wed, 16 Nov 2022 04:15:52 -0500 X-MC-Unique: dIuxcO3vOyWzUZUknMUIHw-1 Received: by mail-wr1-f72.google.com with SMTP id i12-20020adfaacc000000b0023cd08e3b56so3488269wrc.12 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=794dkbuBsZ+XmaUAzcfyr9VAOr8fD9pX1XowENchqafrcNoRa0r4oee6nchmgfKWkU 2f/Xljkke8s1F5TXNeM/GMnfDcjI/wfjoJ+tVjELwbmbV+xIAgJ51JJPDH1Vt3uv68yh Q415MFqRyUABuXWXAb3zcVRsgHJL30X8c4oCFcW4MfYngOyZWGSAZbm66Bos5f0lY/7k BZrRS4GNwSblzPV489dd9J4FhM4ikhnTyxhwu2jw/nN/Y1uqDcSl6JzHU5LjYbNNt82p 4Lg/4eSau1+wy4oxINgpI5tkXySomve9hIO6xVY0G/l1yGPLCvVlthuFWxVmmDQ1uqGt GKBw== X-Gm-Message-State: ANoB5pmd1Rts8JhU021Rq3FjZNjf8puglEURFJsPmY4T12hOoRdLy6Tl 5/A4c8Qid6OmtSB/rZIWpfvJcaw38r50MMvgHhBOexfXlF1AzbkaJ7kO/ojRf3B/rB/6Ud2xPFH xwYGrFsx28sM2bhXKxdRXOhw8 X-Received: by 2002:adf:ba8a:0:b0:241:a825:205c with SMTP id p10-20020adfba8a000000b00241a825205cmr723883wrg.40.1668590151410; Wed, 16 Nov 2022 01:15:51 -0800 (PST) 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 Content-Language: en-US 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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