From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76B4D2FAE for ; Wed, 26 May 2021 03:12:53 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 02A7261432 for ; Wed, 26 May 2021 03:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621998773; bh=MXpvYaTxrBbMYL5TsCq9ZgmO4Fjlx82C4mGQi4aVHMQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RDS16tZOAnUn3k9cCdeS2YltDG71HjGjF6DshnjdQerRxKvMbluLiTGgeKMxti/HG 7aKfQDnvbRY3cSrRZK+yXr6iuD8WR5/SRnfFqMSe44afXIsBS2Z1t6xEXTYCDPBATs E87XsLrS8I6B0/n3jVVRThZrNOUSRVY3D/qk2yfygT2s7KZpyKz9VDAKsBZTLZ7Aoo +3xGTx54NhFKpj3TJdNXy3znpnsv8gv6jYMUh+Owo7BDQfeHqo1LpBAgKoCTvfddYy 6EhEnBQaMhzLO5EfCyV9KgzVCtYPjHNWJ1lPNjwbaVRqJUAXpbjwkTLUbJd303vhgd V5ksjA8Rh0m6g== Received: by mail-lf1-f46.google.com with SMTP id r5so290451lfr.5 for ; Tue, 25 May 2021 20:12:52 -0700 (PDT) X-Gm-Message-State: AOAM530tSVKOiY1t04VC2fXKYaWrWXBaDjXMGHvz6V5oPYhbeONrnnEz lKtiEXg4+CScwD+4CxFNVZ7ocC2zREuRfSEoLhE= X-Google-Smtp-Source: ABdhPJxKd0AZEQrvaUMDv5kZQPzNDqbPCo1Mhq9I+ttONfouWDsr+H6nCx4ue2MWBb0o0jMYAc3c4zelSHKaO+tByNU= X-Received: by 2002:a19:c49:: with SMTP id 70mr579450lfm.555.1621998771385; Tue, 25 May 2021 20:12:51 -0700 (PDT) X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <1621945447-38820-1-git-send-email-guoren@kernel.org> <1621945447-38820-3-git-send-email-guoren@kernel.org> <20210525123556.GB4842@lst.de> In-Reply-To: <20210525123556.GB4842@lst.de> From: Guo Ren Date: Wed, 26 May 2021 11:12:40 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V3 2/2] riscv: Use use_asid_allocator flush TLB To: Christoph Hellwig Cc: Anup Patel , Palmer Dabbelt , Arnd Bergmann , linux-riscv , Linux Kernel Mailing List , linux-arch , linux-sunxi@lists.linux.dev, Guo Ren Content-Type: text/plain; charset="UTF-8" On Tue, May 25, 2021 at 8:35 PM Christoph Hellwig wrote: > > On Tue, May 25, 2021 at 12:24:07PM +0000, guoren@kernel.org wrote: > > From: Guo Ren > > > > Use static_branch_unlikely(&use_asid_allocator) to keep the origin > > tlb flush style, so it's no effect on the existing machine. Here > > are the optimized functions: > > - flush_tlb_mm > > - flush_tlb_page > > - flush_tlb_range > > > > All above are based on the below new implement functions: > > - __sbi_tlb_flush_range_asid > > - local_flush_tlb_range_asid > > > This mentiones what functions you're changing, but not what the > substantial change is, and more importantly why you change it. > > > +static inline void local_flush_tlb_range_asid(unsigned long start, unsigned long size, > > + unsigned long asid) > > Crazy long line. Should be: > > static inline void local_flush_tlb_range_asid(unsigned long start, > unsigned long size, unsigned long asid) > > > +{ > > + unsigned long tmp = start & PAGE_MASK; > > + unsigned long end = ALIGN(start + size, PAGE_SIZE); > > + > > + if (size == -1) { > > + __asm__ __volatile__ ("sfence.vma x0, %0" : : "r" (asid) : "memory"); > > + return; > > Please split the global (size == -1) case into separate helpers. Do you mean: if (size == -1) { __asm__ __volatile__ ("sfence.vma x0, %0" : : "r" (asid) : "memory"); } else { for (tmp = start & PAGE_MASK; tmp < end; tmp += PAGE_SIZE) { __asm__ __volatile__ ("sfence.vma %0, %1" : : "r" (tmp), "r" (asid) : "memory"); tmp += PAGE_SIZE; } } > > > + while(tmp < end) { > > Missing whitespace befre the (. > > Also I think this would read nicer as: > > for (tmp = start & PAGE_MASK; tmp < end; tmp += PAGE_SIZE) > > > +static void __sbi_tlb_flush_range_asid(struct cpumask *cmask, unsigned long start, > > + unsigned long size, unsigned long asid) > > Another overly long line. > > Also for all thee __sbi_* functions, why the __ prefix? I just follow the previous coding convention by __sbi_tlb_flush_range. If you don't like it, I think it should be another coding convention patchset. This patchset is only to add the functions of tlb_flush_with_asid. > > > + if (cpumask_any_but(cmask, cpuid) >= nr_cpu_ids) { > > + local_flush_tlb_range_asid(start, size, asid); > > + } else { > > + riscv_cpuid_to_hartid_mask(cmask, &hmask); > > + sbi_remote_sfence_vma_asid(cpumask_bits(&hmask), start, size, asid); > > Another long line (and a few more later). -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ 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 X-Spam-Level: X-Spam-Status: No, score=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B02ECC2B9F7 for ; Wed, 26 May 2021 03:12:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92B7E6113D for ; Wed, 26 May 2021 03:12:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231685AbhEZDO1 (ORCPT ); Tue, 25 May 2021 23:14:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:47390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhEZDOX (ORCPT ); Tue, 25 May 2021 23:14:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0AA9A6113D; Wed, 26 May 2021 03:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621998773; bh=MXpvYaTxrBbMYL5TsCq9ZgmO4Fjlx82C4mGQi4aVHMQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RDS16tZOAnUn3k9cCdeS2YltDG71HjGjF6DshnjdQerRxKvMbluLiTGgeKMxti/HG 7aKfQDnvbRY3cSrRZK+yXr6iuD8WR5/SRnfFqMSe44afXIsBS2Z1t6xEXTYCDPBATs E87XsLrS8I6B0/n3jVVRThZrNOUSRVY3D/qk2yfygT2s7KZpyKz9VDAKsBZTLZ7Aoo +3xGTx54NhFKpj3TJdNXy3znpnsv8gv6jYMUh+Owo7BDQfeHqo1LpBAgKoCTvfddYy 6EhEnBQaMhzLO5EfCyV9KgzVCtYPjHNWJ1lPNjwbaVRqJUAXpbjwkTLUbJd303vhgd V5ksjA8Rh0m6g== Received: by mail-lf1-f51.google.com with SMTP id i9so249783lfe.13; Tue, 25 May 2021 20:12:52 -0700 (PDT) X-Gm-Message-State: AOAM532hlIGlshwFJ+CMiVID0z+98Fenj6g8IBslvaCpYOyW/+oVAkQQ lpZNQ5CeQPYdWqnrTX8ERvzpeImVieamVgTsk+U= X-Google-Smtp-Source: ABdhPJxKd0AZEQrvaUMDv5kZQPzNDqbPCo1Mhq9I+ttONfouWDsr+H6nCx4ue2MWBb0o0jMYAc3c4zelSHKaO+tByNU= X-Received: by 2002:a19:c49:: with SMTP id 70mr579450lfm.555.1621998771385; Tue, 25 May 2021 20:12:51 -0700 (PDT) MIME-Version: 1.0 References: <1621945447-38820-1-git-send-email-guoren@kernel.org> <1621945447-38820-3-git-send-email-guoren@kernel.org> <20210525123556.GB4842@lst.de> In-Reply-To: <20210525123556.GB4842@lst.de> From: Guo Ren Date: Wed, 26 May 2021 11:12:40 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V3 2/2] riscv: Use use_asid_allocator flush TLB To: Christoph Hellwig Cc: Anup Patel , Palmer Dabbelt , Arnd Bergmann , linux-riscv , Linux Kernel Mailing List , linux-arch , linux-sunxi@lists.linux.dev, Guo Ren Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 8:35 PM Christoph Hellwig wrote: > > On Tue, May 25, 2021 at 12:24:07PM +0000, guoren@kernel.org wrote: > > From: Guo Ren > > > > Use static_branch_unlikely(&use_asid_allocator) to keep the origin > > tlb flush style, so it's no effect on the existing machine. Here > > are the optimized functions: > > - flush_tlb_mm > > - flush_tlb_page > > - flush_tlb_range > > > > All above are based on the below new implement functions: > > - __sbi_tlb_flush_range_asid > > - local_flush_tlb_range_asid > > > This mentiones what functions you're changing, but not what the > substantial change is, and more importantly why you change it. > > > +static inline void local_flush_tlb_range_asid(unsigned long start, unsigned long size, > > + unsigned long asid) > > Crazy long line. Should be: > > static inline void local_flush_tlb_range_asid(unsigned long start, > unsigned long size, unsigned long asid) > > > +{ > > + unsigned long tmp = start & PAGE_MASK; > > + unsigned long end = ALIGN(start + size, PAGE_SIZE); > > + > > + if (size == -1) { > > + __asm__ __volatile__ ("sfence.vma x0, %0" : : "r" (asid) : "memory"); > > + return; > > Please split the global (size == -1) case into separate helpers. Do you mean: if (size == -1) { __asm__ __volatile__ ("sfence.vma x0, %0" : : "r" (asid) : "memory"); } else { for (tmp = start & PAGE_MASK; tmp < end; tmp += PAGE_SIZE) { __asm__ __volatile__ ("sfence.vma %0, %1" : : "r" (tmp), "r" (asid) : "memory"); tmp += PAGE_SIZE; } } > > > + while(tmp < end) { > > Missing whitespace befre the (. > > Also I think this would read nicer as: > > for (tmp = start & PAGE_MASK; tmp < end; tmp += PAGE_SIZE) > > > +static void __sbi_tlb_flush_range_asid(struct cpumask *cmask, unsigned long start, > > + unsigned long size, unsigned long asid) > > Another overly long line. > > Also for all thee __sbi_* functions, why the __ prefix? I just follow the previous coding convention by __sbi_tlb_flush_range. If you don't like it, I think it should be another coding convention patchset. This patchset is only to add the functions of tlb_flush_with_asid. > > > + if (cpumask_any_but(cmask, cpuid) >= nr_cpu_ids) { > > + local_flush_tlb_range_asid(start, size, asid); > > + } else { > > + riscv_cpuid_to_hartid_mask(cmask, &hmask); > > + sbi_remote_sfence_vma_asid(cpumask_bits(&hmask), start, size, asid); > > Another long line (and a few more later). -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ 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 X-Spam-Level: X-Spam-Status: No, score=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6706C2B9F7 for ; Wed, 26 May 2021 03:13:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6245361432 for ; Wed, 26 May 2021 03:13:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6245361432 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=03it8NVPP/BV66uQEY6nIMSWnDCX7ksPKnnmyNlaXaE=; b=uLKOPdNSDFmyue nAqHfN1AYBTwEFBxkEOZrgG1QcMEq4emeWHdsjn7oq0g/yNcG6OtWpihh0V4nx9qi4euFtUEKwpeh PoL+KUed2OTyZMeP5X1uM4j44oFn2ylPDXdxp8bnqveiFNHUmDbcRWPdtVeNEoSloknSrT1hjCr4P PsK111gg93sT39FnAfg1QcmBDHoOKS8Xef3mRbxBdnqcKcYLdivblXRE8U6tI0Vw5Dm58lM28bFxC tVx7BYKmrigMKU/81k2ZBtD/R9FQk9B2LdWG0XCKo2VLAb9bxf3WBnXzUfdqkVjJsjAp6BK3FDY+0 OH4q2yxyJf7O+6BCliGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lljyZ-00ASsU-Hb; Wed, 26 May 2021 03:12:55 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lljyX-00ASr3-GS for linux-riscv@lists.infradead.org; Wed, 26 May 2021 03:12:55 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 18EEC61436 for ; Wed, 26 May 2021 03:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621998773; bh=MXpvYaTxrBbMYL5TsCq9ZgmO4Fjlx82C4mGQi4aVHMQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RDS16tZOAnUn3k9cCdeS2YltDG71HjGjF6DshnjdQerRxKvMbluLiTGgeKMxti/HG 7aKfQDnvbRY3cSrRZK+yXr6iuD8WR5/SRnfFqMSe44afXIsBS2Z1t6xEXTYCDPBATs E87XsLrS8I6B0/n3jVVRThZrNOUSRVY3D/qk2yfygT2s7KZpyKz9VDAKsBZTLZ7Aoo +3xGTx54NhFKpj3TJdNXy3znpnsv8gv6jYMUh+Owo7BDQfeHqo1LpBAgKoCTvfddYy 6EhEnBQaMhzLO5EfCyV9KgzVCtYPjHNWJ1lPNjwbaVRqJUAXpbjwkTLUbJd303vhgd V5ksjA8Rh0m6g== Received: by mail-lf1-f47.google.com with SMTP id q3so308603lfu.2 for ; Tue, 25 May 2021 20:12:53 -0700 (PDT) X-Gm-Message-State: AOAM530BjPdWtYgQvtAwQ7YCDAcoSaAdOPGCwlcQTzlKQ6Bz4YuS6I4c 4Xu6ih4HaanLfqUxJvwEYejqDt/obtFnVwncJlA= X-Google-Smtp-Source: ABdhPJxKd0AZEQrvaUMDv5kZQPzNDqbPCo1Mhq9I+ttONfouWDsr+H6nCx4ue2MWBb0o0jMYAc3c4zelSHKaO+tByNU= X-Received: by 2002:a19:c49:: with SMTP id 70mr579450lfm.555.1621998771385; Tue, 25 May 2021 20:12:51 -0700 (PDT) MIME-Version: 1.0 References: <1621945447-38820-1-git-send-email-guoren@kernel.org> <1621945447-38820-3-git-send-email-guoren@kernel.org> <20210525123556.GB4842@lst.de> In-Reply-To: <20210525123556.GB4842@lst.de> From: Guo Ren Date: Wed, 26 May 2021 11:12:40 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V3 2/2] riscv: Use use_asid_allocator flush TLB To: Christoph Hellwig Cc: Anup Patel , Palmer Dabbelt , Arnd Bergmann , linux-riscv , Linux Kernel Mailing List , linux-arch , linux-sunxi@lists.linux.dev, Guo Ren X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210525_201253_619140_8AF6132E X-CRM114-Status: GOOD ( 20.89 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, May 25, 2021 at 8:35 PM Christoph Hellwig wrote: > > On Tue, May 25, 2021 at 12:24:07PM +0000, guoren@kernel.org wrote: > > From: Guo Ren > > > > Use static_branch_unlikely(&use_asid_allocator) to keep the origin > > tlb flush style, so it's no effect on the existing machine. Here > > are the optimized functions: > > - flush_tlb_mm > > - flush_tlb_page > > - flush_tlb_range > > > > All above are based on the below new implement functions: > > - __sbi_tlb_flush_range_asid > > - local_flush_tlb_range_asid > > > This mentiones what functions you're changing, but not what the > substantial change is, and more importantly why you change it. > > > +static inline void local_flush_tlb_range_asid(unsigned long start, unsigned long size, > > + unsigned long asid) > > Crazy long line. Should be: > > static inline void local_flush_tlb_range_asid(unsigned long start, > unsigned long size, unsigned long asid) > > > +{ > > + unsigned long tmp = start & PAGE_MASK; > > + unsigned long end = ALIGN(start + size, PAGE_SIZE); > > + > > + if (size == -1) { > > + __asm__ __volatile__ ("sfence.vma x0, %0" : : "r" (asid) : "memory"); > > + return; > > Please split the global (size == -1) case into separate helpers. Do you mean: if (size == -1) { __asm__ __volatile__ ("sfence.vma x0, %0" : : "r" (asid) : "memory"); } else { for (tmp = start & PAGE_MASK; tmp < end; tmp += PAGE_SIZE) { __asm__ __volatile__ ("sfence.vma %0, %1" : : "r" (tmp), "r" (asid) : "memory"); tmp += PAGE_SIZE; } } > > > + while(tmp < end) { > > Missing whitespace befre the (. > > Also I think this would read nicer as: > > for (tmp = start & PAGE_MASK; tmp < end; tmp += PAGE_SIZE) > > > +static void __sbi_tlb_flush_range_asid(struct cpumask *cmask, unsigned long start, > > + unsigned long size, unsigned long asid) > > Another overly long line. > > Also for all thee __sbi_* functions, why the __ prefix? I just follow the previous coding convention by __sbi_tlb_flush_range. If you don't like it, I think it should be another coding convention patchset. This patchset is only to add the functions of tlb_flush_with_asid. > > > + if (cpumask_any_but(cmask, cpuid) >= nr_cpu_ids) { > > + local_flush_tlb_range_asid(start, size, asid); > > + } else { > > + riscv_cpuid_to_hartid_mask(cmask, &hmask); > > + sbi_remote_sfence_vma_asid(cpumask_bits(&hmask), start, size, asid); > > Another long line (and a few more later). -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv