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 507D5C433F5 for ; Tue, 19 Apr 2022 22:01:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D4B16B0072; Tue, 19 Apr 2022 18:01:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95E086B0073; Tue, 19 Apr 2022 18:01:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 787736B0074; Tue, 19 Apr 2022 18:01:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 630AA6B0072 for ; Tue, 19 Apr 2022 18:01:20 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 395FB223BB for ; Tue, 19 Apr 2022 22:01:20 +0000 (UTC) X-FDA: 79375000320.10.5743D42 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 26858160010 for ; Tue, 19 Apr 2022 22:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650405679; 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: in-reply-to:in-reply-to:references:references; bh=ZOf+5gwAGn9Ts5LxNHedJ7Kx9vDnu9lMiJ3VpD8HDhA=; b=MI+89Dk4S2HZ/xEYp25hYi784sd9K5hvGzODaIbfCcTIk2lYNZuPVvpOv5bHGr8ZwpxyDc xVlnt2jFI/M3RSG57W1CcMjJfEWIKrhen0U/Y77g3rsKpaKtf3SV6iaxA9OSDTOYmqM6u4 r+7hm8mgIzX/3CbB2BRXeMDan8KkZ0M= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-345-dnVwVeEbPuelxTv6tFkong-1; Tue, 19 Apr 2022 18:01:18 -0400 X-MC-Unique: dnVwVeEbPuelxTv6tFkong-1 Received: by mail-io1-f71.google.com with SMTP id m8-20020a0566022e8800b00654992238ceso5034964iow.23 for ; Tue, 19 Apr 2022 15:01:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZOf+5gwAGn9Ts5LxNHedJ7Kx9vDnu9lMiJ3VpD8HDhA=; b=wu9/HwLLJEAWxa7u1wSjdkTVovbJOpt8D3miPTEUpItnb0wOkF21Fezw+IJteYlXJg TjcITUU4ZcdO8IfTB5plVD785O/IQCxBXwF6tbvhwjR9JuoohHCXTTBI3e79Zq7vNoWe aLevhzT4SzEgp3gD0dZw/5eXfoXPlEmwhvKeczvo+JRBQ67gFgR08yeL5l4QasIp5/BG 3kPlgYtS15QzdA1+ZrcUV+N0O5jsjolepxUY9XajcLE0FCyN/Ndnwo80vsC8PzI8lDht 6PgcgymyXHDM70IMRI07LOo3+Zo9u4bKd9wtOU1d7nv9L0b5SgLaJ9jzNntTKq2Jhz6S IsCw== X-Gm-Message-State: AOAM533iBFxSYiEPbjWkDkqQDuRBB1KMQaqvOxbA+TDVNFhilYHWwzqY xUc7PzA5PXHUff31FPoUJOy23wT9R44VJH5/qInCgxCauv7VocqcQi4gkEdCnLLbQEnzMsRddUK bOadgTDQ71Vo= X-Received: by 2002:a05:6638:22c6:b0:328:71e2:82ae with SMTP id j6-20020a05663822c600b0032871e282aemr6878459jat.53.1650405677504; Tue, 19 Apr 2022 15:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysIQX/isqxiYMJbIumIYuEy9U9dE8+h3bDbqGUIUbOg8yZ0lTGpnjp1xu/9nv2HyYaRHJhwA== X-Received: by 2002:a05:6638:22c6:b0:328:71e2:82ae with SMTP id j6-20020a05663822c600b0032871e282aemr6878446jat.53.1650405677186; Tue, 19 Apr 2022 15:01:17 -0700 (PDT) Received: from xz-m1.local (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id x186-20020a6bc7c3000000b00648deae6630sm10979284iof.54.2022.04.19.15.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 15:01:16 -0700 (PDT) Date: Tue, 19 Apr 2022 18:01:14 -0400 From: Peter Xu To: Johannes Weiner Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mike Kravetz , Nadav Amit , Matthew Wilcox , Mike Rapoport , David Hildenbrand , Hugh Dickins , Jerome Glisse , "Kirill A . Shutemov" , Andrea Arcangeli , Andrew Morton , Axel Rasmussen , Alistair Popple Subject: Re: [PATCH v8 22/23] mm: Enable PTE markers by default Message-ID: References: <20220405014646.13522-1-peterx@redhat.com> <20220405014929.15158-1-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 26858160010 X-Stat-Signature: kmsz39zsf5uxibed51dxw3oq5crff46t Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MI+89Dk4; spf=none (imf08.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1650405677-95182 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 Tue, Apr 19, 2022 at 05:24:28PM -0400, Johannes Weiner wrote: > On Tue, Apr 19, 2022 at 04:28:16PM -0400, Peter Xu wrote: > > On Tue, Apr 19, 2022 at 04:14:11PM -0400, Johannes Weiner wrote: > > > On Tue, Apr 19, 2022 at 03:59:21PM -0400, Peter Xu wrote: > > > > @@ -910,16 +910,16 @@ config ANON_VMA_NAME > > > Btw, this doesn't do much without userfaultfd being enabled in > > > general, right? > > > > So far yes, but I'm thinking there can be potential other users of > > PTE_MARKERS from mm world. The most close discussion is on the swap read > > failures and this patch proposed by Miaohe: > > > > https://lore.kernel.org/lkml/20220416030549.60559-1-linmiaohe@huawei.com/ > > > > So I hope we can still keep them around here under mm/ if possible, and > > from the gut feeling it really should.. > > Agreed, mm/ seems a good fit for PTE_MARKER. > > If it's invisible and gets selected as needed, it's less of a concern, > IMO. I'm somewhat worried about when and how the user-visible options > show up right now, though... > > > > Would it make sense to have it next to 'config USERFAULTFD' as a > > > sub-option? > > > > Yes another good question. :) > > > > IIUC CONFIG_USERFAULTFD resides in init/Kconfig because it introduces a new > > syscall. Same to the rest of the bits for uffd since then, namely: > > > > - USERFAULTFD_WP > > - USERFAULTFD_MINOR > > > > What I am thinking now is the other way round of your suggestion: whether > > we should move most of them out, at least the _WP and _MINOR configs into > > mm/? Because IMHO they are really pure mm ideas and they're irrelevant to > > syscalls and init. > > I'm thinking the MM submenu would probably be a better fit for all > user-visible userfaultfd options, including the syscall. Like you say, > it's an MM concept. > > But if moving the syscall knob out from init isn't popular, IMO it > would be better to add the new WP option to init as well. This ensures > that when somebody selects userfaultfd, they also see the relevant > suboptions and don't have to chase them down across multiple submenus. > > Conversely, they should also have the necessary depend clauses so that > suboptions aren't visible without the main feature. E.g. it asked me > for userfaultd options even though I have CONFIG_USERFAULTFD=n. Hmm, this is a bit weird... since we do have that dependency chain for PTE_MARKER_UFFD_WP -> HAVE_ARCH_USERFAULTFD_WP -> USERFAULTFD: in arch/x86/Kconfig: config X86 ... select HAVE_ARCH_USERFAULTFD_WP if X86_64 && USERFAULTFD in mm/Kconfig (with/without the "mm/uffd: Hide PTE_MARKER" patch applied): config PTE_MARKER_UFFD_WP ... depends on HAVE_ARCH_USERFAULTFD_WP So logically if !USERFAULTFD we shouldn't see PTE_MARKER_UFFD_WP at all? That's also what I got when I tried it out for either !USERFAULTFD on x86, or any non-x86 platforms (because there we have !HAVE_ARCH_USERFAULTFD_WP constantly irrelevant of USERFAULTFD). Though I could have missed something.. > > What do you think? I don't have a strong preference here, I think it's okay if it's preferred that we only put user-visible configs into mm/Kconfig. It's just that I see we have tons of user-invisible configs already in mm/Kconfig, to list some: config ARCH_HAS_HUGEPD config MAPPING_DIRTY_HELPERS config KMAP_LOCAL config KMAP_LOCAL_NON_LINEAR_PTE_ARRAY But I'm not sure whether it's a rule of thumb somewhere else. At the meantime, I also looked at whether syscall configs are always and only be put under init/, and funnily I got: $ find . -name Kconfig | xargs grep --color -E "\".*syscall.*\"" ./init/Kconfig: bool "Enable process_vm_readv/writev syscalls" ./init/Kconfig: bool "uselib syscall" ./init/Kconfig: bool "sgetmask/ssetmask syscalls support" if EXPERT ./init/Kconfig: bool "Sysfs syscall support" if EXPERT ./init/Kconfig: bool "open by fhandle syscalls" if EXPERT ./init/Kconfig: bool "Enable madvise/fadvise syscalls" if EXPERT ./arch/xtensa/Kconfig: bool "Enable fast atomic syscalls" ./arch/xtensa/Kconfig: bool "Enable spill registers syscall" ./arch/powerpc/Kconfig: bool "Support setting protections for 4k subpages (subpage_prot syscall)" ./arch/powerpc/Kconfig: bool "Enable filtering of RTAS syscalls" ./arch/Kconfig: bool "Support for randomizing kernel stack offset on syscall entry" if EXPERT ./arch/s390/Kconfig: bool "Verify kernel signature during kexec_file_load() syscall" ./arch/sh/mm/Kconfig: bool "Support vsyscall page" ./arch/x86/Kconfig: bool "Enable vsyscall emulation" if EXPERT ./arch/x86/Kconfig: bool "Verify kernel signature during kexec_file_load() syscall" ./arch/x86/Kconfig: bool "Require a valid signature in kexec_file_load() syscall" ./arch/x86/Kconfig: prompt "vsyscall table for legacy applications" ./arch/arm64/Kconfig: bool "Verify kernel signature during kexec_file_load() syscall" ./arch/arm64/Kconfig: bool "Enable the tagged user addresses syscall ABI" ./kernel/trace/Kconfig: bool "Trace syscalls" ./kernel/trace/Kconfig: bool "Run selftest on syscall events" So let's put aside arch specific lines, ftrace does have FTRACE_SYSCALLS that lies in the kernel/trace/ dir.. not sure whether we could move USERFAULTFD and all the rest into mm/ as well? Or perhaps that's just a bad example? :) Thanks, -- Peter Xu