From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (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 3159445BE3 for ; Wed, 29 Jul 2026 04:00:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785297653; cv=none; b=TwthUaR74m0f833Qt6bTPak7ippn7cmMArZdIenSUmd2byuhbonxGIEpoY2IzvqD7zlQjn01uGljXsSH9gSnNtKrwWC8gb8Gc81Cl0sZhTasfDS8dufuCZOqGkVLN5lpQQZcUuKT3q8Fr8WWQKxY9hv155xZKMixyTuMyH4fvXM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785297653; c=relaxed/simple; bh=EcF0AU3VL+2F4sud0IwmkLvG9LowSbftmeNHNtv3Cf8=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=alWbshMlSCN71jL7F9zPRNGZozbs9130divA01AIZLQLzPUavu2a6BeqdIegyj6Um75g7nt3AVSloQt+Qcog6HhdGXFEmOKlmJgb9VUWGvpMkJbBPgw1uepxSSa3Hyu0IOlIEds5UmODt9UmeAA57/KiCOs2skGq+Z+YeKLt3IM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=bEFnSR+l; arc=none smtp.client-ip=113.46.200.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="bEFnSR+l" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=g61n9d1IViPkUAiOWnNWq2bymq99oNhhk+FJJvFjI8M=; b=bEFnSR+lII8hQtAlMaNPv3Qvjm9ZgAvZZvtgzKjkAs8+H5PjQuRI4Sf3/qmOeGfF149dr7xii SNWBPF3ZJBbTiiV6gSA0jPxn13QOZOsys0UpZw3XrNVs79KqDNO7lgwK/23S9nNZ9C0j1Ou9oVv zmMP0DOc3D8SI87bRUI2lNg= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4h8z005krKzmV91; Wed, 29 Jul 2026 11:51:12 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id D60B340565; Wed, 29 Jul 2026 12:00:39 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 29 Jul 2026 12:00:38 +0800 Message-ID: <9f28ee32-d0cf-4297-9a41-03d499273ff8@huawei.com> Date: Wed, 29 Jul 2026 12:00:38 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 02/13] arm64: preempt: Treat should_resched() as unlikely To: Mark Rutland , CC: , , , , , , , , , References: <20260728123859.2911495-1-mark.rutland@arm.com> <20260728123859.2911495-3-mark.rutland@arm.com> From: Jinjie Ruan In-Reply-To: <20260728123859.2911495-3-mark.rutland@arm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To dggpemf500011.china.huawei.com (7.185.36.131) 在 2026/7/28 20:38, Mark Rutland 写道: > The arm64 implementation of should_resched() doesn't treat the need to > resched as unlikely, while all other implementations do, e.g. > > * asm-generic since: > bdb43806589096ac ("sched: Extract the basic add/sub preempt_count modifiers") > > * x86 since: > c2daa3bed53a8117 ("sched, x86: Provide a per-cpu preempt_count implementation") > > * s390 since: > c360192bf4a8dc72 ("s390/preempt: move preempt_count to the lowcore") > > Do the same for arm64. > > Signed-off-by: Mark Rutland > Cc: Ada Couprie Diaz > Cc: Ard Biesheuvel > Cc: Catalin Marinas > Cc: Jinjie Ruan > Cc: Marc Zyngier > Cc: Peter Zijlstra > Cc: Vladimir Murzin > Cc: Will Deacon > Cc: Yang Shi > --- > arch/arm64/include/asm/preempt.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h > index ca2ad1a8db095..3ef24ab8f3399 100644 > --- a/arch/arm64/include/asm/preempt.h > +++ b/arch/arm64/include/asm/preempt.h > @@ -58,7 +58,7 @@ static inline void __preempt_count_sub(int val) > static inline bool should_resched(int preempt_offset) > { > u64 pc = READ_ONCE(current_thread_info()->preempt_count); > - return pc == preempt_offset; > + return unlikely(pc == preempt_offset); It is rare that preempt_count is 0 or a specific value. Therefore, it is reasonable to use unlikely. Reviewed-by: Jinjie Ruan > } > > static inline bool __preempt_count_dec_and_test(void)