Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5664031rwb; Tue, 9 Aug 2022 01:48:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR5UBpYUUH4K+HvzjK375wjtldcD8v0VW/lxgJTN0CqH6q+kJNPpZ3m5Mx9+Dz6tC4J92bcF X-Received: by 2002:a50:fc89:0:b0:43c:bf1e:165d with SMTP id f9-20020a50fc89000000b0043cbf1e165dmr20430948edq.161.1660034890112; Tue, 09 Aug 2022 01:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660034890; cv=none; d=google.com; s=arc-20160816; b=YpS8tfYHIRgk/XS45N/KhFLHEqJ+UymhpmU4lRHW1Ywau++o5H0EMLJNRkLqc5ofxH ryf8UZp7KHzJ8omVQxyjEe/irNZTMzcMn+5Rc1XvKmjy21bx3cTHRffadi7hVqx9q9Q6 t7RaURaIjUi3N5Ofc+TRiyyzPzQJDglPJzQRHHTG6xKNjcWKdiEQ+Zg41UUbK56Wxp33 xb2HcKyHX9HSKOxzTYbpvP+01lAHIYU35nEc5vBBDt20YutKrAYtAcnwBT0drExVcwZx CZgqBI6w/xZIpl+yTscqktU4j/Ephuo9+k05yJAj10UvsUlUTdmUBelxSrO9Xfu/cwQA d5bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=u/RS0k5tySHOV4StoluNhQ+iW6eGkK3C5YkTwsVEtqs=; b=Xq1JMDQUWCH1CDJAYUp2M2Uw09eJMReHhfSDhbQFgMETHmF8DF+Xpj901t6R4Ic5XU SsxHrHTGnX84oTxKadxAFvwHPRibVEEyAdxsy+Jx3h4ZKN8hGILCVop8whkHVz8s19t8 98WmPEHqrmuYmi1nxFwhm1AVWnG0zrMDd7+oTfTIcTo72RHPbMaSItdI/xCJWs2ZoShQ gN+UR7G2VBJGNlHxuhFsqRRi4QEy9H8bAEinmiHuZQYYu9KQJ/InOmMQFAgpoRzOZAEH 7WUkNqV+E+JtNOHdJRvkwN4/tGoq0qsZvIqt28mRnZmFgvN1Y4U5wJ6uCQF0kSGtKJMg C+jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mOJBHjwq; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15-20020a50d5cf000000b0043a7cdf26aasi251158edj.85.2022.08.09.01.47.43; Tue, 09 Aug 2022 01:48:10 -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=@intel.com header.s=Intel header.b=mOJBHjwq; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233351AbiHIIpv (ORCPT + 99 others); Tue, 9 Aug 2022 04:45:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233614AbiHIIpj (ORCPT ); Tue, 9 Aug 2022 04:45:39 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF3796350 for ; Tue, 9 Aug 2022 01:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660034738; x=1691570738; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=Z9+RwjgfJBkrpirf/lbuc83Z7Jh6lUPmK3soFoYeQ3I=; b=mOJBHjwqNvxt1UajKsI+6KGUgqBCO8Zh7VfJ520ye0HNEMnOzRM5YyN/ jRzRxNi3sPigflR6HSWDvGJmxbJLCGf6oxRgAJrpx5RgiE+K75jpnR+sj jcAPgMhyLXtslLRTg8iOH3jQELJg0Twh7TWZNuqFImBz+XXIUGWDEUd7T y3QjRf1e3/0begEMazzQ1/yxN2oHHLP04+AIhr9H2VY/09jcHDD3YLyVr kNwnwO+BuKylwvvsgtKjUKFknrFl6+6xIA7+bV/Z3zxAL4xdzD4bnUyMt Bw7KG7G3V9NDOmHU27a1+0WTiEHOwOgznwLJVR18RH9gkOElyvIlVj3tl Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10433"; a="291574936" X-IronPort-AV: E=Sophos;i="5.93,224,1654585200"; d="scan'208";a="291574936" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 01:45:38 -0700 X-IronPort-AV: E=Sophos;i="5.93,224,1654585200"; d="scan'208";a="580715048" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 01:45:35 -0700 From: "Huang, Ying" To: Peter Xu Cc: Nadav Amit , Linux MM , linux-kernel@vger.kernel.org, Andrea Arcangeli , David Hildenbrand , Minchan Kim , Andrew Morton , Vlastimil Babka , Hugh Dickins , Andi Kleen , "Kirill A . Shutemov" Subject: Re: [PATCH v2 2/2] mm: Remember young/dirty bit for page migrations References: <20220804203952.53665-1-peterx@redhat.com> <20220804203952.53665-3-peterx@redhat.com> Date: Tue, 09 Aug 2022 16:45:32 +0800 In-Reply-To: (Peter Xu's message of "Fri, 5 Aug 2022 12:30:08 -0400") Message-ID: <8735e5hkk3.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 Peter Xu writes: > On Thu, Aug 04, 2022 at 03:40:57PM -0700, Nadav Amit wrote: >> On Aug 4, 2022, at 1:39 PM, Peter Xu wrote: >> > + >> > static inline bool is_pfn_swap_entry(swp_entry_t entry); >> > >> > /* Clear all flags but only keep swp_entry_t related information */ >> > @@ -265,6 +285,57 @@ static inline swp_entry_t make_writable_migration_entry(pgoff_t offset) >> > return swp_entry(SWP_MIGRATION_WRITE, offset); >> > } >> > >> > +/* >> > + * Returns whether the host has large enough swap offset field to support >> > + * carrying over pgtable A/D bits for page migrations. The result is >> > + * pretty much arch specific. >> > + */ >> > +static inline bool migration_entry_supports_ad(void) >> > +{ >> > + /* >> > + * max_swapfile_size() returns the max supported swp-offset plus 1. >> > + * We can support the migration A/D bits iff the pfn swap entry has >> > + * the offset large enough to cover all of them (PFN, A & D bits). >> > + */ >> > +#ifdef CONFIG_SWAP >> > + return max_swapfile_size() >= (1UL << SWP_MIG_TOTAL_BITS); >> >> This is an actual a function call (unless LTO has some trick). A bit of a >> shame it cannot be at least memoized. >> >> Or at least mark max_swapfile_size() as __attribute_const__ so it would not >> be called twice for make_migration_entry_young() and >> make_migration_entry_dirty(). > > I didn't take too much effort on this one since we're on swap path and I > assumed that's not a super hot path. But __attribute_const__ sounds good > and easy to get, thanks. > > Perhaps I should mark it on migration_entry_supports_ad() as a whole? Note > that unfortunately SWP_MIG_TOTAL_BITS may not be a const either (see how > that define roots back to MAX_PHYSMEM_BITS, where on x86_64 it needs to > check 5-lvl). I think it's possible to memorize max_swapfile_size() or migration_entry_supports_ad(). Although they are not constant, they are not changed after initialized. The challenge is to find a clean way to initialize it. Best Regards, Huang, Ying