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 D33D7C43219 for ; Thu, 24 Nov 2022 21:27:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 736C16B0071; Thu, 24 Nov 2022 16:27:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C0226B0072; Thu, 24 Nov 2022 16:27:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 560726B0073; Thu, 24 Nov 2022 16:27:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 42EC36B0071 for ; Thu, 24 Nov 2022 16:27:14 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0AF031A0201 for ; Thu, 24 Nov 2022 21:27:14 +0000 (UTC) X-FDA: 80169621588.20.8747EEF Received: from mail-vs1-f41.google.com (mail-vs1-f41.google.com [209.85.217.41]) by imf18.hostedemail.com (Postfix) with ESMTP id A71D51C0004 for ; Thu, 24 Nov 2022 21:27:13 +0000 (UTC) Received: by mail-vs1-f41.google.com with SMTP id 124so2545160vsv.4 for ; Thu, 24 Nov 2022 13:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=28tlNzvFGezHHKEtEMJ65MUgCLg/C1dGauYsgv5qA68=; b=GbHa/hQqiNB8uEN5hR06CtMISUCk0+DFPYBaPzprj2cbOIt0q9mQGnPzI6StE+f+w1 5gkxjit+Yafa9jRoElTfiGKyOiKEO/vCsLn9PbP+MJewxX+igI5Hq8C5sO6UE2CmxqWo Ea5ew7UUXgyzyiTntfH3siZuqb79Io8P7DAErhnMEby6tH/s4tXkgtmmvxESluGnKfqh k2Ny/v+BmhIFBaT70hqkodeJLCBf/3/GAwIwJDAwb/nk+oLNxgkYuXKuSgX5tb2VjSTP srWaNlgTbqqzm4yBJx95uLT7U6DhjRqNMja20tXksmMpNM7PCo9+yY0Xv6PJ5NHtsl21 Zm9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=28tlNzvFGezHHKEtEMJ65MUgCLg/C1dGauYsgv5qA68=; b=fQmynQu2K2TN/OQbIgkq1w4TdJqT6iP60cpICq/yOBL1OwYYnnEzohKhQVDNwNaVgy ZbYneM0qZ5lVczXxT9QmNvsP9mJL2gVvay5WehjTptijf0Gsv4GDkSuXMBrjtRYPbF/N dj7HmGzQgKl4Vti6Vi1bbiv1utho8uypwsU1gQFoq4zD0zFx/u8MhpuT9GAYJntXLO7t CoFiOb+BnJmQ+lniC8cCqqZS26vM/AJBBWeXrtqF8DKdvJXQxPt279KMAxgp98O13cBT hJgCfIAW+FX8eTzvEzy/9vWR3LQyExgguqQVGiy+8OP4CgygV1ChmxDFYZoW2pF8yz2I zLbQ== X-Gm-Message-State: ANoB5pnnOetS3zZIs9XKsKlhAdrxzfU7KT22TLuJwO9LRaRhjnfi7jUh WFKycAHtaLmBpRBGYO3srJDfJ0sYFsoFDM9u75n5zQ== X-Google-Smtp-Source: AA0mqf43M80m/yI/Xb9LWXsijHcW8xT1p0hu/+Isbwt0GnHBzigxSsVOq2FF/RFZvI86YR5Y+v162KuSlAiV8o32+0g= X-Received: by 2002:a67:fe01:0:b0:3af:5ff9:ed51 with SMTP id l1-20020a67fe01000000b003af5ff9ed51mr12230257vsr.46.1669325232670; Thu, 24 Nov 2022 13:27:12 -0800 (PST) MIME-Version: 1.0 References: <20221123064510.16225-1-jgross@suse.com> In-Reply-To: From: Yu Zhao Date: Thu, 24 Nov 2022 14:26:36 -0700 Message-ID: Subject: Re: [PATCH v2] mm: introduce arch_has_hw_nonleaf_pmd_young() To: Juergen Gross Cc: Geert Uytterhoeven , linux-kernel@vger.kernel.org, x86@kernel.org, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andrew Morton , Sander Eikelenboom Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669325233; a=rsa-sha256; cv=none; b=COlrF2tLtkK3d/I9IwT4B+nQmNY8+8Gk+RJMEFZ/bfHdEeZNK439veQmg3w8cELDPGcBfH WTrNfYfUzsVIJUAXCtuv18cXZWniNcj4y2rnQi3Ob9x3vvQSpbD5oqdBy3uHn7FSUIcB70 w9cXIpPyUrbvUxbkFQDQ0GaUGebIIqE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="GbHa/hQq"; spf=pass (imf18.hostedemail.com: domain of yuzhao@google.com designates 209.85.217.41 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669325233; 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=28tlNzvFGezHHKEtEMJ65MUgCLg/C1dGauYsgv5qA68=; b=XLKqsqoQHrGlLXnwTr8zj83cIIvYHP7fBJt6GDoUHKijTRWPoWS2GKrteu3tnYwaelFmxq a3sZqppeffXjQBSMPNsQyCVNFLZXs+3y5bXqpxD/O99UWNV0LBSe8MNnbQc+CBXyZoR1Jf TEHTAycOtZPTn8j/Et2BgJVLAMsLJsM= X-Stat-Signature: ija3e8648z69arec8hkefmfp5rd4j1od X-Rspamd-Queue-Id: A71D51C0004 X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="GbHa/hQq"; spf=pass (imf18.hostedemail.com: domain of yuzhao@google.com designates 209.85.217.41 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam10 X-HE-Tag: 1669325233-850915 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: On Thu, Nov 24, 2022 at 7:30 AM Juergen Gross wrote: > > Hi, > > On 24.11.22 15:08, Geert Uytterhoeven wrote: > > Hi J=C3=BCrgen, > > > > On Wed, Nov 23, 2022 at 7:53 AM Juergen Gross wrote: > >> When running as a Xen PV guests commit eed9a328aa1a ("mm: x86: add > >> CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG") can cause a protection violation > >> in pmdp_test_and_clear_young(): > >> > >> BUG: unable to handle page fault for address: ffff8880083374d0 > >> #PF: supervisor write access in kernel mode > >> #PF: error_code(0x0003) - permissions violation > >> PGD 3026067 P4D 3026067 PUD 3027067 PMD 7fee5067 PTE 801000000833706= 5 > >> Oops: 0003 [#1] PREEMPT SMP NOPTI > >> CPU: 7 PID: 158 Comm: kswapd0 Not tainted 6.1.0-rc5-20221118-doflr+ = #1 > >> RIP: e030:pmdp_test_and_clear_young+0x25/0x40 > >> > >> This happens because the Xen hypervisor can't emulate direct writes to > >> page table entries other than PTEs. > >> > >> This can easily be fixed by introducing arch_has_hw_nonleaf_pmd_young(= ) > >> similar to arch_has_hw_pte_young() and test that instead of > >> CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG. > >> > >> Fixes: eed9a328aa1a ("mm: x86: add CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG") > >> Reported-by: Sander Eikelenboom > >> Signed-off-by: Juergen Gross > >> Acked-by: Yu Zhao > >> Tested-by: Sander Eikelenboom > >> --- > >> V2: > >> - correct function name in commit message to match patch > > > > Thanks for your patch, which is now commit 3f85e711d5af4fb4 ("mm: > > introduce arch_has_hw_nonleaf_pmd_young()") in next-20221124. > > > > noreply@ellerman.id.au reported a build failure for m68k/allmodconfig, > > which I have bisected to this commit. > > > >> --- a/mm/vmscan.c > >> +++ b/mm/vmscan.c > > > >> @@ -4073,14 +4073,14 @@ static void walk_pmd_range(pud_t *pud, unsigne= d long start, unsigned long end, > >> #endif > >> walk->mm_stats[MM_NONLEAF_TOTAL]++; > >> > >> -#ifdef CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG > >> - if (get_cap(LRU_GEN_NONLEAF_YOUNG)) { > >> + if (arch_has_hw_nonleaf_pmd_young() && > >> + get_cap(LRU_GEN_NONLEAF_YOUNG)) { > >> if (!pmd_young(val)) > > > > mm/vmscan.c:4102:30: error: implicit declaration of function > > 'pmd_young'; did you mean 'pte_young'? > > [-Werror=3Dimplicit-function-declaration] > > > > pmd_young() seems to be defined only on a handful of architectures. > > What would be the preferred fix for that? > > I could offer: > > - use V1 of the patch > - add the #ifdefs again to this patch (which would be kind of weird) > - use the attached patch Your patch looks good to me: Acked-by: Yu Zhao Thanks.