Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2069055lqt; Sun, 21 Apr 2024 23:39:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUoGIGrKOaiGe6Ci+jQQtk9sSAXZ30zOiUiyqHbg4nkw46MGQRLQqCaH0OamLfOTJylB2x5o0B3/9OqDIcsJB42/c1XKIgExscZBcTmZQ== X-Google-Smtp-Source: AGHT+IGuMbslwcwmwlxaHR4SItW+wXpvjuKnTUhxIMnzcwWtlL3kvusjqy/cNAgispEuFu0rwhqE X-Received: by 2002:a05:6a20:d492:b0:1a7:c67:82ff with SMTP id im18-20020a056a20d49200b001a70c6782ffmr14158626pzb.13.1713767969857; Sun, 21 Apr 2024 23:39:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713767969; cv=pass; d=google.com; s=arc-20160816; b=YGKMPTMHAEC6pkN7837d1NqsoYAIItEW6tyhN0rX/NSAY4276qaiCWbW+OAdgMtj8H FWcJ3InFDqIZuazp4V8HqqRa51Su8izFNka2Dq+cBVMkz16kuFHzYfCmTCs/V61Wmf6g uuKJcWZEDb+2aZ/R9coANhSb/yEzx2/AV3h4OOpteZoa461pGLk8tZX+p27FfP5nbw+T 7kars9rUCZzNcnXTotl+JwgwASmIRuKfa3SjFiueNfxAIUjJmQTfWJn5o12Ca5ogRqd3 +8X8IQyuWaahlPI7NYQboohBcszGtYNA9kNboZV3D6giZjNszbxEKjdZV/HgY/KaxFPJ h5nA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=DFTiIIshBt3nHGS/4A3nNNzLGmWXkp5ut7bbz0K7Lek=; fh=47+IaX/snzq/0tk9HLmYFhjo7tbRXHk8QgxcNJutlUc=; b=BeBHfswM485Mdp/xCSkAPs80mwSOBUofljbS6dBnraZkRIvGtED6ksROwbCuSEMU7R KQ3s+kzziX5mIyBa3tvVD8UHnPVPcPbe5It4grVSVLtGhuNgg3ORBWf/awuGAOTmPw8M dEmoBbslNj8qvkAHDbGOV75BFc9FyRMd5eJriKqmWYrGYbXeQKg+3KM/5dgPN8R7rTmi nK3caLHUD+3rtMCfGjRNv9jlUjFZCa82SL+JHRshH//+VUCxqttaC78CV5PgIAykqV/H UPqem5flpBkh09fbjYrsUtmcCCopcBZWwfX6161bkJNJ48QHmes84H5fohFV0FuVhUWR J8Qg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xaRojVG7; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-152794-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152794-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e13-20020a17090301cd00b001e2c351f5b6si7353006plh.449.2024.04.21.23.39.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 23:39:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152794-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xaRojVG7; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-152794-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152794-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 81C4CB21367 for ; Mon, 22 Apr 2024 06:39:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A51AF481BA; Mon, 22 Apr 2024 06:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="xaRojVG7" Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (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 C9C583A1A2 for ; Mon, 22 Apr 2024 06:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713767957; cv=none; b=hbiU1b4bDHCP30j7pDZcAe35u91yCKPe1MCUXtEk40M1XbIa4/idcgNEWofE1+xqE76KDQLu5E9LX82REBqLIBiryMLLlL1ZFL9dX6adHbRXRIpJ4eYBgMderhN0/zzuMYrqkh8sKWK/UoPCwf7SQAmDkSEd/BsI2drV08HnuiM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713767957; c=relaxed/simple; bh=4PuvvSrgrUY9QfAUKjuGoS3AnOhcCgoDp78Xl1PJe2w=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mPW4ku23PTwL/S62DoDElQbamGpmMwm9sCCNFKv1VVOHZFTAaaF8/b/qIPl9BJUls27Et811Zj2r/VbF/UOq/1rKG41Yvt58HqrUs5XawsSTl5sjeTlPcjMU5vNbaMMaJNb+lim/5FrPiRZqqektHB/bxie8txzLGv1zYzn+Fq4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xaRojVG7; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713767953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DFTiIIshBt3nHGS/4A3nNNzLGmWXkp5ut7bbz0K7Lek=; b=xaRojVG7IT4jnM4Vnz7YUbaEUPe5r+mDIGUtMHukl/XaZ4VHG4ehNm8Yg3VsimU7se0ek0 VHPVBoNMot79mURJlOpZ3hEYGKx1UjBRwPa35FTDf5PuLeE+pEE53XHqdCDk7erVT4O+M3 33XbPTDnLBmKHLJ83uX4t/uhK3BBbUE= From: George Guo To: peterz@infradead.org, jpoimboe@kernel.org, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, George Guo Subject: [PATCH 1/1] arm64: optimize code duplication in arch_static_branch/_jump function Date: Mon, 22 Apr 2024 14:38:53 +0800 Message-Id: <20240422063853.3568733-1-dongtai.guo@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: George Guo Extracted the jump table definition code from the arch_static_branch and arch_static_branch_jump functions into a macro JUMP_TABLE_ENTRY to reduce code duplication and improve readability. Signed-off-by: George Guo --- arch/arm64/include/asm/jump_label.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h index 6aafbb789991..69407b70821e 100644 --- a/arch/arm64/include/asm/jump_label.h +++ b/arch/arm64/include/asm/jump_label.h @@ -15,16 +15,19 @@ #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE +#define JUMP_TABLE_ENTRY \ + ".pushsection __jump_table, \"aw\" \n\t" \ + ".align 3 \n\t" \ + ".long 1b - ., %l[l_yes] - . \n\t" \ + ".quad %c0 - . \n\t" \ + ".popsection \n\t" + static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch) { asm goto( "1: nop \n\t" - " .pushsection __jump_table, \"aw\" \n\t" - " .align 3 \n\t" - " .long 1b - ., %l[l_yes] - . \n\t" - " .quad %c0 - . \n\t" - " .popsection \n\t" + JUMP_TABLE_ENTRY : : "i"(&((char *)key)[branch]) : : l_yes); return false; @@ -37,11 +40,7 @@ static __always_inline bool arch_static_branch_jump(struct static_key * const ke { asm goto( "1: b %l[l_yes] \n\t" - " .pushsection __jump_table, \"aw\" \n\t" - " .align 3 \n\t" - " .long 1b - ., %l[l_yes] - . \n\t" - " .quad %c0 - . \n\t" - " .popsection \n\t" + JUMP_TABLE_ENTRY : : "i"(&((char *)key)[branch]) : : l_yes); return false; -- 2.34.1