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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 04B3DC46467 for ; Tue, 3 Jan 2023 17:23:58 +0000 (UTC) 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RjsVePtlQqF8RW6ZpQjPUHqaW6nyNYNAW3uXsaMix84=; b=p+wOj6NERlNi/p B/27V/qAOX/I+krKhKs9iwcxgUG7tS8drIyZQkzZSoBwOrTCE+rkoK8oQM3X4Ga304Dg4jBbuB05U LVg6iV27QvsHWb3nVw86wwLq8TjzlqH/Mmd3dfb+cVqdg9YMoMxeJxMuhhVyDKinAsxTBCH8YDxUB HE+vUSv9xhIdRsJArY1UEw/mP60idHtd9mb4AWVvwUVRBKAORoSZLjiJACHUbnsTtNZXzCkhk85Hz RKl/QoAZEV5Q/j2yxbPMX3EF+g2MU4KBqU/TZ/Og3l4+WLzcf4RyMXMMZPzzajdKs+8zZzeQXTF5B WRoZ0d22CAsjUwKYmFrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCkzr-003MRG-VU; Tue, 03 Jan 2023 17:22:44 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCiNA-0020nh-Dw for linux-arm-kernel@lists.infradead.org; Tue, 03 Jan 2023 14:34:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QMZBZ22IGBh45Cf/NuWC5djX29Cio7BfdtoICqFLw8c=; b=vzoZM0xwgbok6IYxVXqs12zdCr TuabIQ9nU3oiOJcpn9227fxmFE4ePZADHDcPzbXP9D4grvwld0YCZER64IK63BKVAL5Nri8yfouF5 UozlfO+LfJiiOOCzwcuhQ0Ps85nz22Bii8JwmXzQW8TZ8xzxRI145iD+s2S50qh/ed/fZsjfhukqA 84NvaCAM9zCsi2EUdYd+esPEM1WXtvVCvi15lC30pD97myua40DT4pM/82lz/YSb781nVP3v28Qts C5hg2a5MKZeQNYrm7Z+LdV3NhgU71wYvzsi2WgPF14ceGCYvTa6HYqdghaNekCBRPW2nt7hPI1NMv 60ptpCyA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:35932) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pCiN2-0005QQ-2I; Tue, 03 Jan 2023 14:34:27 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pCiMz-00028E-7l; Tue, 03 Jan 2023 14:34:25 +0000 Date: Tue, 3 Jan 2023 14:34:25 +0000 From: "Russell King (Oracle)" To: Jens Axboe Cc: Hui Tang , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [bug-report] possible performance problem in ret_to_user_from_irq Message-ID: References: <7ecb8f3c-2aeb-a905-0d4a-aa768b9649b5@huawei.com> <50a5ebdb-4107-26cc-a2f6-da551d99ff38@kernel.dk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <50a5ebdb-4107-26cc-a2f6-da551d99ff38@kernel.dk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230103_063436_553214_E28BC3DF X-CRM114-Status: GOOD ( 25.35 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jan 03, 2023 at 07:25:26AM -0700, Jens Axboe wrote: > On 1/3/23 3:06?AM, Russell King (Oracle) wrote: > > On Mon, Dec 26, 2022 at 04:45:20PM +0800, Hui Tang wrote: > >> hi folks. > >> > >> I found a performance problem which is introduced by commit > >> 32d59773da38 ("arm: add support for TIF_NOTIFY_SIGNAL"). > >> After the commit, any bit in the range of 0..15 will cause > >> do_work_pending() to be invoked. More frequent do_work_pending() > >> invoked possible result in worse performance. > >> > >> Some of the tests I've done? as follows: > >> lmbench test base with patch > >> ./lat_ctx -P 1 -s 0 2 7.3167 11.04 > >> ./lat_ctx -P 1 -s 16 2 8.0467 14.5367 > >> ./lat_ctx -P 1 -s 64 2 7.8667 11.43 > >> ./lat_ctx -P 1 -s 16 16 16.47 18.3667 > >> ./lat_pipe -P 1 28.1671 44.7904 > >> > >> libMicro-0.4.1 test base with patch > >> ./cascade_cond -E -C 200\ > >> -L -S -W -N "c_cond_1" -I 100 286.3333 358 > >> > >> When I adjust test bit, the performance problem gone. > >> - movs r1, r1, lsl #16 > >> + ldr r2, =#_TIF_WORK_MASK > >> + tst r1, r2 > >> > >> Does anyone have a good suggestion for this problem? > >> should just test _TIF_WORK_MASK, as before? > > > > I think it should be fine - but I would suggest re-organising the > > TIF definitions so that those TIF bits that shouldn't trigger > > do_work_pending are not in the first 16 bits. > > > > Note that all four bits in _TIF_SYSCALL_WORK need to stay within > > an 8-bit even-bit-aligned range, so the value is suitable for an > > immediate assembly constant. > > > > I'd suggest moving the TIF definitions for 20 to 19, and 4..7 to > > 20..23, and then 8 to 4. > > Like this? > > diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h > index aecc403b2880..7f092cb55a41 100644 > --- a/arch/arm/include/asm/thread_info.h > +++ b/arch/arm/include/asm/thread_info.h > @@ -128,15 +128,16 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, > #define TIF_NEED_RESCHED 1 /* rescheduling necessary */ > #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ > #define TIF_UPROBE 3 /* breakpointed or singlestepping */ > -#define TIF_SYSCALL_TRACE 4 /* syscall trace active */ > -#define TIF_SYSCALL_AUDIT 5 /* syscall auditing active */ > -#define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */ > -#define TIF_SECCOMP 7 /* seccomp syscall filtering active */ > -#define TIF_NOTIFY_SIGNAL 8 /* signal notifications exist */ > +#define TIF_NOTIFY_SIGNAL 4 /* signal notifications exist */ > > #define TIF_USING_IWMMXT 17 > #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ > -#define TIF_RESTORE_SIGMASK 20 > +#define TIF_RESTORE_SIGMASK 19 > +#define TIF_SYSCALL_TRACE 20 /* syscall trace active */ > +#define TIF_SYSCALL_AUDIT 21 /* syscall auditing active */ > +#define TIF_SYSCALL_TRACEPOINT 22 /* syscall tracepoint instrumentation */ > +#define TIF_SECCOMP 23 /* seccomp syscall filtering active */ > + > > #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) > #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) Yep, LGTM, thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel