Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp792031pxb; Wed, 13 Apr 2022 12:27:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc7YOcinDhMhVizkFxmjgKz9LaFQqeOFdbBO0GaBWQArdiCbFAdvAX5V7hoxP6TT/e8bO7 X-Received: by 2002:a17:902:ecc4:b0:158:29c6:f9b7 with SMTP id a4-20020a170902ecc400b0015829c6f9b7mr26436065plh.21.1649878075926; Wed, 13 Apr 2022 12:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649878075; cv=none; d=google.com; s=arc-20160816; b=UoI4GwWFFHTHvQYOXPg0FAJMpBXdmo4wV00ta+SWXRvC/MxP+sc1UeJFZE2x/mK0Yi tHVIKnEEahqWXXO4ggAj8wtgpN2YH/iLDtAXjb4g73rdHlnUtr2tUWTbuwkmIYI7EGYY zH8sR1TlwBetM/SCLqXjg9LNmlIG7AfL8CkVQv4oN5e6pYjK6ZAOuylCJbaXTSA1qd0N r4rLeYHA0691Z/S3PM34iwwbIJ6B+Md6LxluZUCksfOEHUG1HW9dIfl55YTjOZYIJVLk vhnS+vNOqJBDx/B+k8joTVcl0fEOWou7Bpfd7v1OkB+exqpz+dcNfYPy8mEupIuKcs4a UHYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ro34hzAbcJVjT1LhfOk0PtbkoZnNb5Sauq79FJCYyMg=; b=tH511uJd+dYfbluB2S7fSfg/MLticzLntH7KF2L5VrGn+HIaD6RYKxrI4R5p1N7Ty1 NnocY/rwuEu4bTdn1WieOcWkh+4458R5QLi0nTu3FbFLHZHXV6YpqdDCoJowa4+q+pY7 B3qdm+mNxwHuXydh9ivJzwzKkn0LPsOOm1o2xhLNQqHSn+Xh9W+ErRFEL6qKV5NhbclR XrBUWIwgtwTFTgjG0Msohk+SV2umqfRVLCTAS9zozTX4a5pApOwmS9mRDTjjaKu48E8v svwRkE+2RMjwOOkfl30fD9Le7mrinDotIYFkvF/BccEPknvEc0paARDYxiINp9YMtoQ0 njmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TQw7UBPR; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020aa78e14000000b004fa86593770si14028478pfr.145.2022.04.13.12.27.41; Wed, 13 Apr 2022 12:27:55 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=TQw7UBPR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236272AbiDMOuq (ORCPT + 99 others); Wed, 13 Apr 2022 10:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236249AbiDMOup (ORCPT ); Wed, 13 Apr 2022 10:50:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B82D644E5; Wed, 13 Apr 2022 07:48:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A3AE961CD2; Wed, 13 Apr 2022 14:48:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDB28C385A4; Wed, 13 Apr 2022 14:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649861303; bh=FgczV9vyyhtmBq+7sQB2zbK2zkbVOySmGyJEOuInnlc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TQw7UBPRl43qPWUCP2erzWWaWPQNsx70yocpG64iBv2l/aAtgrwO3qsNv+dq2+Ch5 JU7LOh8SUpkXyAOfn0+SnN+NSLeR0dhUGW+m4a7/20guJtrgLblegv5sNemLcgPqKl 6J9FTjAKTpFtGRTENxV8SurPZxzU+o/DiJl5sBZXY5wBhL1MObXsp+5qrg/fRxl1JX x9+TXStgVboZIpoQYAV1bAyaKsDvgEai2GQhwx1z7TDTwAp5kz7qfxpKf9bfGC8w8k OETaHeX9pWfVR+5+xQP4RoU2bnZst5FCD2aKRDDi1+lWvsAToUjeX4fbXza6rrXPK2 UlrExmZwnqSbw== Date: Wed, 13 Apr 2022 17:48:09 +0300 From: Mike Rapoport To: "Kirill A. Shutemov" Cc: Dave Hansen , "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , Brijesh Singh , David Hildenbrand , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: Re: [PATCHv4 1/8] mm: Add support for unaccepted memory Message-ID: References: <20220405234343.74045-1-kirill.shutemov@linux.intel.com> <20220405234343.74045-2-kirill.shutemov@linux.intel.com> <767c2100-c171-1fd3-6a92-0af2e4bf3067@intel.com> <20220409155423.iv2arckmvavvpegt@box.shutemov.name> <6c976344-fdd6-95cd-2cb0-b0e817bf0392@intel.com> <20220413114001.wdsi2xrm4btrghms@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220413114001.wdsi2xrm4btrghms@box.shutemov.name> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Wed, Apr 13, 2022 at 02:40:01PM +0300, Kirill A. Shutemov wrote: > On Mon, Apr 11, 2022 at 01:07:29PM +0300, Mike Rapoport wrote: > > On Sun, Apr 10, 2022 at 11:38:08PM -0700, Dave Hansen wrote: > > > On 4/9/22 08:54, Kirill A. Shutemov wrote: > > > > On Fri, Apr 08, 2022 at 11:55:43AM -0700, Dave Hansen wrote: > > > > > > >>> if (fpi_flags & FPI_TO_TAIL) > > > >>> to_tail = true; > > > >>> else if (is_shuffle_order(order)) > > > >>> @@ -1149,7 +1192,8 @@ static inline void __free_one_page(struct page *page, > > > >>> static inline bool page_expected_state(struct page *page, > > > >>> unsigned long check_flags) > > > >>> { > > > >>> - if (unlikely(atomic_read(&page->_mapcount) != -1)) > > > >>> + if (unlikely(atomic_read(&page->_mapcount) != -1) && > > > >>> + !PageUnaccepted(page)) > > > >>> return false; > > > >> > > > >> That probably deserves a comment, and maybe its own if() statement. > > > > > > > > Own if does not work. PageUnaccepted() is encoded in _mapcount. > > > > > > > > What about this: > > > > > > > > /* > > > > * page->_mapcount is expected to be -1. > > > > * > > > > * There is an exception for PageUnaccepted(). The page type can be set > > > > * for pages on free list. Page types are encoded in _mapcount. > > > > * > > > > * PageUnaccepted() will get cleared in post_alloc_hook(). > > > > */ > > > > if (unlikely((atomic_read(&page->_mapcount) | PG_unaccepted) != -1)) > > > > Maybe I'm missing something, but isn't this true for any PageType? > > PG_buddy gets clear on remove from the free list, before the chec. > > PG_offline and PG_table pages are never on free lists. Right, this will work 'cause PageType is inverted. I still think this condition is hard to parse and I liked the old variant with !PageUnaccepted() better. Maybe if we wrap the whole construct in a helper it will be less eye hurting. > -- > Kirill A. Shutemov -- Sincerely yours, Mike.