Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1552251pxb; Thu, 14 Apr 2022 08:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq5lTnh05phCvswjtm7rUd7L6ShjwAZf+JlmZOokmgezbowUtUS9AfPJtYLu9sbmD8DV4m X-Received: by 2002:a17:90a:ff17:b0:1cb:a182:9b05 with SMTP id ce23-20020a17090aff1700b001cba1829b05mr4319046pjb.1.1649950342707; Thu, 14 Apr 2022 08:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649950342; cv=none; d=google.com; s=arc-20160816; b=X9rTXqhwqmVoQ9ZXmi4eAcJmKKwhPPuWE7DUQDrtJzSSAcL/HUbMFvzsjQikHwP+0X 00BPNRWq69SDVYzJG29goNGH8RjYIdFF/ATE1ynoOYe9IUrybdPmmDtnjKr623GTYXw8 gypx2L1z/ZwAg0txGFU6VtPEoA5zWz+CrK+vBTidgaiYqTEicoiLms+QKnJMo4rYUi5Z rV7XTtp70O1P6aEGQGlKQrTVii1JLLr5C6bLTTZNW0/EK3eXUwny0ctKmITZPgk8lVRq HPXmLQ4r93EH6KyPZTS4ouQT99VVG55XBtV+Hl4/Qg9UNGUXsDfvwfMt5byvqS6itiyz hc/Q== 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=Bv13rV6k4WMKxNu7fu9rLw9V/NPqf8KioT/e5MxVo2I=; b=csu/l2bLhanPvA1bcxQ+bWKDUord9d482WkaFu3Va84Cp3pSV8A+CMpRm8SgshxxX8 Mkx39nPlNEtqeeIRDJpR4SeitOdzgMVDC6MJMDCUlOMzVqgWGeLfJ1GEvfNmSCsctrHl 4oiIFL5TPYLCCa6sCQUcXNDiY1Knv8+NSQCAwKxKngJ/5+6hAluiFmbbucCRaqT4elfZ 8TGDSAn/iAZUplJHsLtttqrz/j/RzQqAjldeE29bT7fJJrlb1Ot4CvKWO7qn7jotlmJj WFMFVPi53TUIdHRYzM/JcQhXXBYQtzdNxW/k2AKJ9po1j4tTpf/n0Ey8IhzcopkHWn3r Hodg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oxeoUVNx; 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 l73-20020a63914c000000b0039e5d2451f9si2491707pge.299.2022.04.14.08.32.08; Thu, 14 Apr 2022 08:32:22 -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=oxeoUVNx; 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 S237170AbiDMUJ1 (ORCPT + 99 others); Wed, 13 Apr 2022 16:09:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235545AbiDMUJZ (ORCPT ); Wed, 13 Apr 2022 16:09:25 -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 160F47B545; Wed, 13 Apr 2022 13:07:01 -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 A391E61E32; Wed, 13 Apr 2022 20:07:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1BE4C385A3; Wed, 13 Apr 2022 20:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649880420; bh=1lv0TYn1rI0bZiX2xcJLC6rgxIwufGUuDS8PwYZgZZE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oxeoUVNxqagKDTCoBhEg0ZjenI8HlagF6DUcw+G/PXtILlsb/+4C9pEpvNlD3uf3p E1v+kxYnRb8b20Y1YbQOvYk79efC+87JQDK3EzvaIg4gX5CtXbi6K6Z8Gfj7QI0Dop TYMDAmgwT9qN1CC287v6xLZf9RDalh20LNPvfCIJPDQlgqB5MU43zs16zcyjJp3bps aJhxG6La5MxAlJFcJ8YkEprju0ttd6mReGFuXZKsED7A7qu3OrktN/MXqtX+Y6z9Vh jaJNTthb2d6e3Adq6vTyH+gxu4FVqcgI5SXduICpNWFjEqDM466H4gwBr7tIY6rfE8 zQR8zc24UsmKQ== Date: Wed, 13 Apr 2022 23:06:46 +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> <20220413151517.tzd76kzja3424lqu@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220413151517.tzd76kzja3424lqu@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 06:15:17PM +0300, Kirill A. Shutemov wrote: > On Wed, Apr 13, 2022 at 05:48:09PM +0300, Mike Rapoport wrote: > > 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. > > Well the old way to deal with PageUnaccepted() had a flaw: if the page is > PageUnaccepted() it will allow any other page types to pass here. Like > PG_unaccepted + PG_buddy will slide here. It seems to me that there was an implicit assumption that page types are exclusive and PG_unaccepted would break it. > > Maybe if we wrap the whole construct in a helper it will be less eye > > hurting. > > Hm. Any suggestion how such helper could look like? Cannot think of > anything sane. Me neither :( How about updating the comment to be /* * The page must not be mapped to userspace and must not have a * PageType other than PageUnaccepted. * This means that page->_mapcount must be -1 or have only * PG_unaccepted bit cleared. */ if (unlikely((atomic_read(&page->_mapcount) | PG_unaccepted) != -1)) > -- > Kirill A. Shutemov -- Sincerely yours, Mike.