Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5062196rwd; Tue, 23 May 2023 17:44:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BaMYIoTYG9a5gI1LvzHi53iOBLQcyMwunMKCuysyizrw40absIqxW3MXLQYRgLX30SwaW X-Received: by 2002:a05:6a20:3e0c:b0:10a:f5ca:153d with SMTP id m12-20020a056a203e0c00b0010af5ca153dmr9719402pzc.41.1684889055326; Tue, 23 May 2023 17:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684889055; cv=none; d=google.com; s=arc-20160816; b=fYa+x1KtGPYepp4IHb4O3Q8HNQyeCCDmEop3Bzt5v36PgRibNrtWE8vY3zpOdNH1hT gptX2uiZSc0uHmoekKHFr8cyHNHb0QbBE/fq1Q/CGeu8ybStmyQxfCKWYTKnyY0/w4BD 2ZkGrRMllgZfmRKRlvq3r5WUUkYaoSOD0EyxFvFnpuGnonTBNoYmwcmUIuoSR4UCBK+g 7K1eQm4d0IussCKMT912Mtta+FEntRETx2mrOV4fCCrhMyBvnWzjx/owB5kMfzbcdpou aE0btcyd78OhCXh7qoXZVtqOU6r6RfXyrm1rV6GGtlG8/PBpzkWEAet43v20fZ6CsHlX 0o2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QgFNwK4FGCwB9Qe4u4tL+1hl0eboqZoL/lOevcwvc4A=; b=ykOzYxEGoP68mTsPQ7z9rvVUtiiBfdWDxM8WsKvVtk9CQom7MRB0NFzQUI+4NFpoeW /c+ytnv7wZbfU+fS+zh7IPhRBy+me17pslLjDlk8RuseS0FEl3PW5basAj5ftVvKAsOG 5SUsUDfxwj003kZ+36VuF3X7JVtbjTj0WBcRd1qNzGu0xNoC79zGqO4j2YEMzfx4z8G6 PkfGIBle55/Z9u/8TDn+rDHpi++uTkV7hbTkEXRegnSSTDwmgP1pImkJurJkOM1+E1gP Sy7+S4UoNQpx8pFLuVYCdNKYOviRQ14OIqTS1DWoNBGEfLuYLEw2yRiomoyoaAJ/ELhr tipg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Wr7T+5i/"; 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 f26-20020a63381a000000b00530743695d6si107109pga.725.2023.05.23.17.44.03; Tue, 23 May 2023 17:44:15 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Wr7T+5i/"; 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 S238823AbjEXAR7 (ORCPT + 99 others); Tue, 23 May 2023 20:17:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236423AbjEXAR6 (ORCPT ); Tue, 23 May 2023 20:17:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29837B5 for ; Tue, 23 May 2023 17:17:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B718D6376C for ; Wed, 24 May 2023 00:17:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6650C433EF; Wed, 24 May 2023 00:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684887476; bh=9dxLjHPo+SZEGy7KQS3cCv9yVec/7vFxtb4zBAqLmXg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Wr7T+5i/6DQrZylu3WCREvJ2bcO9dFx9j+flmANgbbKwhs3FVnYFrJV967oKEfeyD YaSfFfAdfwU/d4c/BDPMmayNOvc/FfiKVKHsE1Ay4B/b98MeOAAZv3MX7LVnwS1CfX Q88UbGhhrbK1+okbRb5/KhncQQ67FMZMShmeZgmhl3BrDuN0sWCn/FeDXxn5KnII0m wR8vT6zgg42KZZhLyDFnkwNsago373inq3hwEKApu1gWsnsEZlktQlfe8E3PuJm2Bd P3O3ZJLPpzsUU7TRBYQTyH8AJ9Py1nm/Hg426LOqE7Pb5CaeQ1hcY0ORJzf8MtqdLa 1YWM74O5ER+yA== Date: Wed, 24 May 2023 08:06:44 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan Subject: Re: [PATCH] riscv: mm: try VMA lock-based page fault handling first Message-ID: References: <20230523165942.2630-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 On Wed, May 24, 2023 at 01:11:55AM +0800, Jisheng Zhang wrote: > On Wed, May 24, 2023 at 12:59:42AM +0800, Jisheng Zhang wrote: > > Attempt VMA lock-based page fault handling first, and fall back to the > > existing mmap_lock-based handling if that fails. > > > > A simple running the ebizzy benchmark on Lichee Pi 4A shows that > > PER_VMA_LOCK can improve the ebizzy benchmark by about 32.68%. In > > theory, the more CPUs, the bigger improvement, but I don't have any > > HW platform which has more than 4 CPUs. > > > > This is the riscv variant of "x86/mm: try VMA lock-based page fault > > handling first". > > > > Signed-off-by: Jisheng Zhang > > --- > > Any performance numbers are welcome! Especially the numbers on HW > > platforms with 8 or more CPUs. > > PS: run ebizzy as below: > ./ebizzy -mTt your_nr_cpus Sorry, should be ./ebizzy -mTt 2*your_nr_cpus > > > > arch/riscv/Kconfig | 1 + > > arch/riscv/mm/fault.c | 33 +++++++++++++++++++++++++++++++++ > > 2 files changed, 34 insertions(+) > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > index 62e84fee2cfd..b958f67f9a12 100644 > > --- a/arch/riscv/Kconfig > > +++ b/arch/riscv/Kconfig > > @@ -42,6 +42,7 @@ config RISCV > > select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU > > select ARCH_SUPPORTS_HUGETLBFS if MMU > > select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU > > + select ARCH_SUPPORTS_PER_VMA_LOCK if MMU > > select ARCH_USE_MEMTEST > > select ARCH_USE_QUEUED_RWLOCKS > > select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU > > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c > > index 8685f85a7474..eccdddf26f4b 100644 > > --- a/arch/riscv/mm/fault.c > > +++ b/arch/riscv/mm/fault.c > > @@ -286,6 +286,36 @@ void handle_page_fault(struct pt_regs *regs) > > flags |= FAULT_FLAG_WRITE; > > else if (cause == EXC_INST_PAGE_FAULT) > > flags |= FAULT_FLAG_INSTRUCTION; > > +#ifdef CONFIG_PER_VMA_LOCK > > + if (!(flags & FAULT_FLAG_USER)) > > + goto lock_mmap; > > + > > + vma = lock_vma_under_rcu(mm, addr); > > + if (!vma) > > + goto lock_mmap; > > + > > + if (unlikely(access_error(cause, vma))) { > > + vma_end_read(vma); > > + goto lock_mmap; > > + } > > + > > + fault = handle_mm_fault(vma, addr, 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); > > + > > + if (fault_signal_pending(fault, regs)) { > > + if (!user_mode(regs)) > > + no_context(regs, addr); > > + return; > > + } > > +lock_mmap: > > +#endif /* CONFIG_PER_VMA_LOCK */ > > + > > retry: > > mmap_read_lock(mm); > > vma = find_vma(mm, addr); > > @@ -355,6 +385,9 @@ void handle_page_fault(struct pt_regs *regs) > > > > mmap_read_unlock(mm); > > > > +#ifdef CONFIG_PER_VMA_LOCK > > +done: > > +#endif > > if (unlikely(fault & VM_FAULT_ERROR)) { > > tsk->thread.bad_cause = cause; > > mm_fault_error(regs, addr, fault); > > -- > > 2.40.1 > > > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv