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 EA335C19F2D for ; Tue, 9 Aug 2022 08:45:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8426E6B0071; Tue, 9 Aug 2022 04:45:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F2088E0001; Tue, 9 Aug 2022 04:45:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E0AE6B0073; Tue, 9 Aug 2022 04:45:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6004F6B0071 for ; Tue, 9 Aug 2022 04:45:42 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2EA5212018B for ; Tue, 9 Aug 2022 08:45:42 +0000 (UTC) X-FDA: 79779420924.28.E3067C9 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf23.hostedemail.com (Postfix) with ESMTP id 24BBC140152 for ; Tue, 9 Aug 2022 08:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660034740; x=1691570740; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=Z9+RwjgfJBkrpirf/lbuc83Z7Jh6lUPmK3soFoYeQ3I=; b=PXBnpCfrxu0fF9et5Rp396ZQmnSBf6/t5y5rEs4gdOLEK1/FLZoUSStK y0++/4qyadGtgaZZVP1MVwM1q18zC4bM7DD8xwZgXTCzieS6bW5X5S4gt 9QuNbIUNE1GI8eNt8eAfI4H9btg15aWi8yWTrspV3cFUuq1SzlSzNisL6 q6n0ibmXcn/bc+8ffW/aCUFevHo53MhXpwWH6vUAax5gBiiNb7IgWaFrt L2e6Jxh6iHc+aJI3QlMR56QJy/Mreiu+Pq9bUAsyHOFtogPKfuJF9Fwhu stiBrw7vsvpbwkkJdnbNPR/OIBlUjmNOuZRXBPv3wQLL1tBZp6Mm67iuk g==; X-IronPort-AV: E=McAfee;i="6400,9594,10433"; a="273837591" X-IronPort-AV: E=Sophos;i="5.93,224,1654585200"; d="scan'208";a="273837591" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660034740; a=rsa-sha256; cv=none; b=JN+cTImBhiUkWKDEEHlzxTS7NBAdNnA/xwqUvV9UDGjwCYrCrJ3K6/NEWwZaDP8sA3xrvV ZqBX6xPw5FE4Qk/rNcyNEuus4gr4QJEGiT8Vp6k0pnqwkW63dF+Thgt38qfxFUAPMwOwsp lTyPQOTJkgvZHVduHbkZk2HfU8tY2Y0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=PXBnpCfr; spf=pass (imf23.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660034740; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=u/RS0k5tySHOV4StoluNhQ+iW6eGkK3C5YkTwsVEtqs=; b=uq8ckOYtUEa/xfARy44XfIqymezh5JLfV3250yZbG794hfeP71rahh14Y16otG3NWrSkab 8wSgjOxQFHIhkyyFRCGitQEkeBMq8onB1l50JGhDdn2Y8LwE+K1slt+MdqcgCqoS1ghvs3 5mZ0gdCIN4ZKXzQNINllmKd4JtxxLS0= X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: hd8rb977qd1keipbxh3qyu61xqrabtrh X-Rspamd-Queue-Id: 24BBC140152 Authentication-Results: imf23.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=PXBnpCfr; spf=pass (imf23.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1660034739-572488 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: 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