Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20912067rwd; Thu, 29 Jun 2023 08:30:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fmR6HAG7K05i5KLrQ/VFgop5u03a1+rb2BeVT21Ff2ySRweCEYh1FN5DGOO5c+IzBp9le X-Received: by 2002:a05:6a20:13d4:b0:12a:9e2e:e4d1 with SMTP id ho20-20020a056a2013d400b0012a9e2ee4d1mr51462pzc.13.1688052617309; Thu, 29 Jun 2023 08:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688052617; cv=none; d=google.com; s=arc-20160816; b=AgoNMD+G6Uzxu3vhMu82mp9b8M2F0YCmh4K2By50hq79IdDUIob0Zy5o8I7UW6Zm+E AoY0xq/XPF6TFSAf6KaU2U7o01QxYhErgiOmLRGm6KK0EKdSJr6oaoq54QCcW+RwWWCI ajFkG6rY0JxU6Yq/jR+yD33Le64WgrocHhoLTMGrFPlaO3mcJJgpTQEnMAd/kEu5gEpZ YouKTT59y4ndhrs7aSdid68twuxMoFrOJb9y8wUqNaqB7Brcscch2I2mmRoQlyS5y/0T MerBCcf1jNM3d1uNcEuOf/8IIE5WNUts0e22B9h8mmyEVPXn88r6ZMrB5hxyAF7PGNnf tK5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=acfeDV6ig1DAYnhU+FrQZ3QnlBZlpv5iySwPYFbbjOg=; fh=cLAy7zQXmH+KPBchWOjD+3rYriic+Fnfw1UyJNDhFbM=; b=UfxSC0+mr3dngjM0QgCcYEGF5qmPGS5n6sunRWE7Mj5wBnFE4qMnK1+5pzVAPRVQ3b ritvyG10rVxCpmqEKsqOqHPyEITcgujVAClqzJ9x+/SHc3CJHz5yNUDNJ95JQPp5GDvf ChTN9NggE2ocHVtonXnwnxP2X9zMVNCM6B9DQftdFreJv9GaAg/rFoPQg3stOOXks5H5 +9MZ7Wrzn3LbSBK9tug17zLEUI2EoSNBNlK6hh91W/kSnfHxsWAPqytq/knQdqa+bTZc 6y5CRelxsXSqUjuNpMJknBMDy2a6l1IPE9ktX13EY+NtImsx7gEipO/xvkPD/FBcLm9D tS0Q== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd35-20020a056a0027a300b006824f156b00si850319pfb.346.2023.06.29.08.30.03; Thu, 29 Jun 2023 08:30:17 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbjF2Okv (ORCPT + 99 others); Thu, 29 Jun 2023 10:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbjF2Oku (ORCPT ); Thu, 29 Jun 2023 10:40:50 -0400 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CEB4BC for ; Thu, 29 Jun 2023 07:40:49 -0700 (PDT) Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-51d9890f368so926023a12.2 for ; Thu, 29 Jun 2023 07:40:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688049648; x=1690641648; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=acfeDV6ig1DAYnhU+FrQZ3QnlBZlpv5iySwPYFbbjOg=; b=Yat7jBUESNhoX5nDFB4j+dGQlpcUHZ3VQvLdNwamdJiykssdJbPC8Bzi+6d1MGJdn0 N7o7Lwt3rMZNd892opuqu/L9dnT/F1dheMUHoRBgE0vhWJLH21D/U/qtkplS8eKonhXC Wf1t8y7jIw1V0fwds85eLXkEbc7IzcJyIkaQL0YZrP+x2rKsaV88sDZcvGKntBoPXO11 MOrxkwl7jt0kyLxsINOhio/kIWvl+mqFFv7U+/PEuHFqLMF+xfDCo14SlE1rk3tQWCq0 MDz06fMpbIN66Dn0PcaRBek2w8jsYU/xLD+gfxlMAuazhEEDnS5aTUR+agd7VFNLwCRD vNmw== X-Gm-Message-State: AC+VfDyP3xQfu5GcokHquFw3EfAgW8uid0uYXeCDPYZCOyzHJkSmn7XV I3HGA6cNw27slnttulhbtzQ= X-Received: by 2002:a17:907:2cce:b0:991:de8e:4f99 with SMTP id hg14-20020a1709072cce00b00991de8e4f99mr8222804ejc.70.1688049647620; Thu, 29 Jun 2023 07:40:47 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:59? ([2a0b:e7c0:0:107::aaaa:59]) by smtp.gmail.com with ESMTPSA id lh8-20020a170906f8c800b009923998c8acsm2760768ejb.20.2023.06.29.07.40.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jun 2023 07:40:47 -0700 (PDT) Message-ID: Date: Thu, 29 Jun 2023 16:40:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v4 29/33] x86/mm: try VMA lock-based page fault handling first Content-Language: en-US To: Suren Baghdasaryan , akpm@linux-foundation.org Cc: michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, paulmck@kernel.org, mingo@redhat.com, will@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, chriscli@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, rppt@kernel.org, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, leewalsh@google.com, posk@google.com, michalechner92@googlemail.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com References: <20230227173632.3292573-1-surenb@google.com> <20230227173632.3292573-30-surenb@google.com> From: Jiri Slaby In-Reply-To: <20230227173632.3292573-30-surenb@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi, On 27. 02. 23, 18:36, Suren Baghdasaryan wrote: > Attempt VMA lock-based page fault handling first, and fall back to the > existing mmap_lock-based handling if that fails. > > Signed-off-by: Suren Baghdasaryan > --- > arch/x86/Kconfig | 1 + > arch/x86/mm/fault.c | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 37 insertions(+) > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index a825bf031f49..df21fba77db1 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -27,6 +27,7 @@ config X86_64 > # Options that are inherently 64-bit kernel only: > select ARCH_HAS_GIGANTIC_PAGE > select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 > + select ARCH_SUPPORTS_PER_VMA_LOCK > select ARCH_USE_CMPXCHG_LOCKREF > select HAVE_ARCH_SOFT_DIRTY > select MODULES_USE_ELF_RELA > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > index a498ae1fbe66..e4399983c50c 100644 > --- a/arch/x86/mm/fault.c > +++ b/arch/x86/mm/fault.c > @@ -19,6 +19,7 @@ > #include /* faulthandler_disabled() */ > #include /* efi_crash_gracefully_on_page_fault()*/ > #include > +#include /* find_and_lock_vma() */ > > #include /* boot_cpu_has, ... */ > #include /* dotraplinkage, ... */ > @@ -1333,6 +1334,38 @@ void do_user_addr_fault(struct pt_regs *regs, > } > #endif > > +#ifdef CONFIG_PER_VMA_LOCK > + if (!(flags & FAULT_FLAG_USER)) > + goto lock_mmap; > + > + vma = lock_vma_under_rcu(mm, address); > + if (!vma) > + goto lock_mmap; > + > + if (unlikely(access_error(error_code, vma))) { > + vma_end_read(vma); > + goto lock_mmap; > + } > + fault = handle_mm_fault(vma, address, flags | FAULT_FLAG_VMA_LOCK, regs); > + vma_end_read(vma); > + > + if (!(fault & VM_FAULT_RETRY)) { > + count_vm_vma_lock_event(VMA_LOCK_SUCCESS); > + goto done; > + } > + count_vm_vma_lock_event(VMA_LOCK_RETRY); This is apparently not strong enough as it causes go build failures like: [ 409s] strconv [ 409s] releasep: m=0x579e2000 m->p=0x5781c600 p->m=0x0 p->status=2 [ 409s] fatal error: releasep: invalid p state [ 409s] [ 325s] hash/adler32 [ 325s] hash/crc32 [ 325s] cmd/internal/codesign [ 336s] fatal error: runtime: out of memory There are many kinds of similar errors. It happens in 1-3 out of 20 builds only. If I revert the commit on top of 6.4, they all dismiss. Any idea? The downstream report: https://bugzilla.suse.com/show_bug.cgi?id=1212775 > + > + /* Quick path to respond to signals */ > + if (fault_signal_pending(fault, regs)) { > + if (!user_mode(regs)) > + kernelmode_fixup_or_oops(regs, error_code, address, > + SIGBUS, BUS_ADRERR, > + ARCH_DEFAULT_PKEY); > + return; > + } > +lock_mmap: > +#endif /* CONFIG_PER_VMA_LOCK */ > + > /* > * Kernel-mode access to the user address space should only occur > * on well-defined single instructions listed in the exception > @@ -1433,6 +1466,9 @@ void do_user_addr_fault(struct pt_regs *regs, > } > > mmap_read_unlock(mm); > +#ifdef CONFIG_PER_VMA_LOCK > +done: > +#endif > if (likely(!(fault & VM_FAULT_ERROR))) > return; > thanks, -- js suse labs