Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4657876rwd; Tue, 23 May 2023 10:30:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MlntTZe4Q11zQzPjf19MDvNiINg58RI7AcuSR9Yp11hgtyUe0wApKtSTe0N+lVYPFV9HP X-Received: by 2002:a17:902:bf0a:b0:1ab:26a8:5401 with SMTP id bi10-20020a170902bf0a00b001ab26a85401mr13264657plb.31.1684863033418; Tue, 23 May 2023 10:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684863033; cv=none; d=google.com; s=arc-20160816; b=zeUa+cVeTy9GjEh2VyDkmEGVfSJ7HfV/tIG0QdQ53YmEJCmelLjGA75H04DNtDyZ+2 UfUO23rq+qhHiQoA95p50+L+AZFn5BT3E5Tqxk4RR0M7qCwsdud5bMcVNOA2/Bmd5IhD aA9C8ireNA/o3OU8AInIMcyOLLmncs66LCl3InBMFFfsxXWAy74MPP5SqC+YNVNUgtQa Z1n9ZoV9oTBuvnYkwUrCRXMGz/sliGHV8u52WstiepioaYXsaopUOAiPG3at9rtu47B2 yak14KcdVOGNq2s6dK/67t8CFArLmtmGn+83S4/hQnXggU+u6oMwXojwL1NuAJL825xQ Z77w== 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=ctReWrNEW2dXcw0dmVBW80v7jTjI1yq6VR0Yd3AjFoA=; b=a9cS9Nx1q6BVyCBh1jzemFgsay5zCMscDwGcJuKh/sXxx7gsbia3cs5fxmaUHCrf09 V3qjd4uxxCf59A5voJdSqD1OapnMen70uQkjC/ZMRqItbOu6kpm0fbVmNVyun8QrSJbj 3wzdeCnJlDmeEuFz9vjiNqVrdx1iWm4ftfc2a/TUwMYuDjJ7OsGLWxnxsI5G0Cd3GDJV CduLgiW0g+JbtFQYdQ6xS+lCBwZk1PyvSRZwKgdp/L+P3+Eq4gJZvXRuBZqg71DeUds2 yKOUZR3rQi0fwXhPlfb1qliO9nrBVEizqHKgkG/m++ca82woPlOMOui5YRO8gLM+WO7x MMqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sCMRTonk; 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 j12-20020a170903024c00b001ac528e3f1bsi2009582plh.154.2023.05.23.10.30.17; Tue, 23 May 2023 10:30:33 -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=sCMRTonk; 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 S238147AbjEWRYL (ORCPT + 99 others); Tue, 23 May 2023 13:24:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238153AbjEWRYC (ORCPT ); Tue, 23 May 2023 13:24:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84A3F97 for ; Tue, 23 May 2023 10:23:36 -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 A99AF63520 for ; Tue, 23 May 2023 17:23:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF46DC4339B; Tue, 23 May 2023 17:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684862583; bh=cx8zpeww/sD91Z30NnLug53CGtDlH+zjbb9NnNcdOEU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sCMRTonkhdZDpAVFf3FDRDrt8zxticbMUfrQw0ryThW0GGGWZRa8VSlJFceOItaoO q7O16UdCT1fj4HHKskFVKM+pMr/Z7r+DMbJBvuXio3ZDxMAqWuTeD/TCwR1MYDfwvG psYZFLPq8gho42SvY0wqHTy7GrNUmanO/IyNtDCGRGC3gDhIDGWyF2s8aSBHNeQM4b TKO1VTauXuPCSS3y2d6Lthhx1dZ/+K0DQA5q7ZAK8d2LAt9JqiVSslK1RyDxHYGprr FbUDfBYbzulbsYjx8778hxObgH7ENXOv9VC2KO6qomVOWjcUZ9VEslCyj8reR9YFMA TAf+kGlDIVxjQ== Date: Wed, 24 May 2023 01:11:51 +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: <20230523165942.2630-1-jszhang@kernel.org> 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 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 > > 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