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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 53926C76589 for ; Thu, 27 Feb 2020 14:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FE8F2468F for ; Thu, 27 Feb 2020 14:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582814130; bh=XC+WPtSkfTm5ePQdr+PHvKYb9iGLo7xCq4HxNroYENU=; h=From:To:Subject:Date:In-Reply-To:References:In-Reply-To: References:List-ID:From; b=HcIZzeLLu3WSWWGpLj7W4rl7W44W0BOWVdSfoSO5K2Eg2msIoanNikt8rlS/Z+7kI Dkuvdw+GOCSF9HbyJzNArQGGxvlx2cv/0TR96eoQ3gD6bUhKb5s0lsnaJ5zBPgpyXd d+E/pgBGX7L7wjHXE0wnKRH/lsdlOGqprKcEgZT0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387693AbgB0OeG (ORCPT ); Thu, 27 Feb 2020 09:34:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:45086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387434AbgB0OeF (ORCPT ); Thu, 27 Feb 2020 09:34:05 -0500 Received: from localhost.localdomain (c-98-220-238-81.hsd1.il.comcast.net [98.220.238.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA247246B1; Thu, 27 Feb 2020 14:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582814044; bh=XC+WPtSkfTm5ePQdr+PHvKYb9iGLo7xCq4HxNroYENU=; h=From:To:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=x0B0/y/zBgjCbMsNzn4PMOOwaNeQLcJaRag7kp/vzs+l3GS1X4A9B/5asiEHb349p tta1we1QLW7MGZOK7myu04khcQWUaSNjRzGw6yMxDPFDS4W4I6LxALtBIhRv3I+iRu 4D2NC+WYK/OcBRsH7RocNrOt+wRBm/f88GtNHV4M= From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Tom Zanussi Subject: [PATCH RT 09/23] lib/smp_processor_id: Don't use cpumask_equal() Date: Thu, 27 Feb 2020 08:33:20 -0600 Message-Id: X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-rt-users-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Waiman Long v4.14.170-rt75-rc2 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit 659252061477862f45b79e1de169e6030f5c8918 ] The check_preemption_disabled() function uses cpumask_equal() to see if the task is bounded to the current CPU only. cpumask_equal() calls memcmp() to do the comparison. As x86 doesn't have __HAVE_ARCH_MEMCMP, the slow memcmp() function in lib/string.c is used. On a RT kernel that call check_preemption_disabled() very frequently, below is the perf-record output of a certain microbenchmark: 42.75% 2.45% testpmd [kernel.kallsyms] [k] check_preemption_disabled 40.01% 39.97% testpmd [kernel.kallsyms] [k] memcmp We should avoid calling memcmp() in performance critical path. So the cpumask_equal() call is now replaced with an equivalent simpler check. Signed-off-by: Waiman Long Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Tom Zanussi --- lib/smp_processor_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c index 6f4a4ae881c8..9f3c8bb62e57 100644 --- a/lib/smp_processor_id.c +++ b/lib/smp_processor_id.c @@ -23,7 +23,7 @@ notrace static unsigned int check_preemption_disabled(const char *what1, * Kernel threads bound to a single CPU can safely use * smp_processor_id(): */ - if (cpumask_equal(current->cpus_ptr, cpumask_of(this_cpu))) + if (current->nr_cpus_allowed == 1) goto out; /* -- 2.14.1