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 5C9E3C19F2D for ; Tue, 9 Aug 2022 08:48:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD7916B0071; Tue, 9 Aug 2022 04:48:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C5FFA6B0072; Tue, 9 Aug 2022 04:48:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD97B8E0001; Tue, 9 Aug 2022 04:48:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 98C9E6B0071 for ; Tue, 9 Aug 2022 04:48:01 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 41C4A1602C8 for ; Tue, 9 Aug 2022 08:48:01 +0000 (UTC) X-FDA: 79779426762.28.1097C9B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 6A9211C0063 for ; Tue, 9 Aug 2022 08:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660034878; 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=5EGFbFs/lIL/rbVEQQvHXXCPRsVB0qqjyg3GENEnkVI=; b=NyFoKPqiklslQgCeQcMcHBQUX6aucZsiNHwaPKeSX6Tv3DMSGcrOvmaSfXMKkDgLpzgNXO 5OgecHTr5uYRFhuv+TrpUK5FdlGgkfFb6Uy0ppGVW8yonXVzV9x87zaLOVOoHOTr1HlxD8 vueuDjNapJRbHq6OgimU8Rr/ae+SPRo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-27-JZn-8T5rMoaIf7GBvnwHjA-1; Tue, 09 Aug 2022 04:47:57 -0400 X-MC-Unique: JZn-8T5rMoaIf7GBvnwHjA-1 Received: by mail-wm1-f69.google.com with SMTP id z11-20020a05600c0a0b00b003a043991610so2080061wmp.8 for ; Tue, 09 Aug 2022 01:47:57 -0700 (PDT) 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; bh=5EGFbFs/lIL/rbVEQQvHXXCPRsVB0qqjyg3GENEnkVI=; b=TXCPw5b50GZJcL4/0iP8307S3LQbkM6yOw5PUF2a1b944N7+gNKIYd7JupEsmVPD/v RLYiWqaUKzNsHWu/mcDOom4H4wNAfzCwu+tkq+VGyIip2WrcB4GTjzn9I2QSkwspUytS kQcQ/dS9NJrqenwdIgZfM17kPaf6E1599zyNTn5sflQAo2pyj3E9A0xeEWyA8FZ2zf76 qC7LpQsqtGNBxnc15U7slkg4WR43+l6mLWUkT/PXwR4U2aoZnv67MJkEMig3I5Y5Z3rJ qwb7pJanGmlNLU4iOzddstMY6Ew/33i5kSAs98lACYiOxR/ddjSgL/BbZ4LmwBAlwvOt 3pUg== X-Gm-Message-State: ACgBeo1kUrglJnCcZ6eR9tqoAxudJwC68a83NkJSvdfHtBc52QKk6QL4 qe59jw3vgt3rmel7H1bzq08mNM8b7uM0kAkD7WS8vGZ/kVjEL5VuPS6v9oziX0KtMc//nzU2JJc UUiUyA40XLz4= X-Received: by 2002:a7b:c7d4:0:b0:3a5:737:3e1e with SMTP id z20-20020a7bc7d4000000b003a507373e1emr14879041wmk.123.1660034876210; Tue, 09 Aug 2022 01:47:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7GkOe3DiUhn6hWYT/VPDPl0RZniR9c9EXzdSmPH2Lktl0vfRlWVelZH/yZ0Dun96bpZJE5Hw== X-Received: by 2002:a7b:c7d4:0:b0:3a5:737:3e1e with SMTP id z20-20020a7bc7d4000000b003a507373e1emr14879030wmk.123.1660034875968; Tue, 09 Aug 2022 01:47:55 -0700 (PDT) Received: from ?IPV6:2003:d8:2f15:c300:d2ce:1fb5:2460:179a? (p200300d82f15c300d2ce1fb52460179a.dip0.t-ipconnect.de. [2003:d8:2f15:c300:d2ce:1fb5:2460:179a]) by smtp.gmail.com with ESMTPSA id g6-20020a05600c4ec600b003a3199c243bsm28577241wmq.0.2022.08.09.01.47.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Aug 2022 01:47:55 -0700 (PDT) Message-ID: Date: Tue, 9 Aug 2022 10:47:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 2/2] mm: Remember young/dirty bit for page migrations To: "Huang, Ying" , Peter Xu Cc: Nadav Amit , Linux MM , linux-kernel@vger.kernel.org, Andrea Arcangeli , Minchan Kim , Andrew Morton , Vlastimil Babka , Hugh Dickins , Andi Kleen , "Kirill A . Shutemov" References: <20220804203952.53665-1-peterx@redhat.com> <20220804203952.53665-3-peterx@redhat.com> <8735e5hkk3.fsf@yhuang6-desk2.ccr.corp.intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <8735e5hkk3.fsf@yhuang6-desk2.ccr.corp.intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660034880; a=rsa-sha256; cv=none; b=qXTf96+3ou749b7T6FOxsVJzHMZlnAbYjNB6XfMLZeUtLYMQGNO3TTBll2OaRt+RWRJHi7 0PhwdV3iufFklsLqnTCHZHFiEE82USA+snXf2Vlx7tT50KGb/Tng5kEcvfBkrKOEJd0DqW vG/TLj3WIxW+5r/SI0gkVpKqUCDRa0c= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NyFoKPqi; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660034880; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5EGFbFs/lIL/rbVEQQvHXXCPRsVB0qqjyg3GENEnkVI=; b=bwKXsVeTG98INQ1PyW9TRpeb7TriSnLR/Yydmt05M5dVYJAyk0uliYhIalwEP6McnG9ZRo AuquK2tp8r/7SydHe7TTNpw/JzUGd64CgLSqQAyT9vKdu3UnoXa/8AdlDZXrpzrI/yVExd 2QW4nL6loeOre2chtOX8t55H7sJ/bdM= X-Stat-Signature: bx9996tpouuri4upau56nozh4taprxid X-Rspamd-Queue-Id: 6A9211C0063 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NyFoKPqi; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1660034879-627445 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 09.08.22 10:45, Huang, Ying wrote: > 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. We could max_swapfile_size()->__max_swapfile_size() and then simply have a new max_swapfile_size() that caches the value in a static variable. If that turns out to be worth the trouble. -- Thanks, David / dhildenb