Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp979131lqd; Thu, 25 Apr 2024 02:25:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDVSlX/maE3TM2FOPYFMXaJylsj4TYQNl7nLfKeKtu38UYkYYW2YDf7YereD1oy+CJ+gOTnitkHZjCjcOpRPAfImw4le8Lc0Y7js+gtA== X-Google-Smtp-Source: AGHT+IGN/OfFA0ekSTAUHcrxKuv9Gc4gJCRwfrwnuJsqEXg0QWRUYVB2xo5c9fQAMQXyIDb6QKU2 X-Received: by 2002:a17:906:f28f:b0:a55:63d8:8ab with SMTP id gu15-20020a170906f28f00b00a5563d808abmr3693957ejb.11.1714037159232; Thu, 25 Apr 2024 02:25:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714037159; cv=pass; d=google.com; s=arc-20160816; b=QMpG8RbVLChzHaga5TXHGl/O6aqDSuB5F6LB3u8ahctffze8GDuQ8Xx0sViWthOwvZ VL8nCkhvMtvZ7Y/6wf5ZsZ3WyXjxd0U/mIkoOX3P8Qx71HggxfhDGJXDgg4VqywrboZA FxO7OzHFMHlwEZG+PNNKQjDQtH5w4uMZSXfmnA82szbBEhZyNVD/ZA8jLwV1kpr2Dqs+ U850m0/s87l1IkXuw6KEzmWBHRDHKSfN2/eSnkcw9DC9Z/07z2f7WS0nZLHDOEBtUP7K j3pAlTbv2iLNpjAHaP9suvqKZvF+xvWpRa2O0OT7H6JCCAYypi6u3YSegHz159SUMESN IvxA== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=DFTiIIshBt3nHGS/4A3nNNzLGmWXkp5ut7bbz0K7Lek=; fh=hyRTPyIvt9LCA9RJVNXJQ4MWZ2svUAfhgZ7mKxgiTYU=; b=ZyrB32kofeVGDP3MnWa2KmijvMb5CgPFyNkn62Hz4RKfm/ocdCLnbCQ2hBWmZ9LLCY aoiC9JN7RuM9J3vJ27E6nTXHxmliipzbEQzjJ5lz2D9uUFgrMtdMzFhd6kv+N/C7Yl5l 3sRbscLlBlz5BRis/aG5CuU2BH5/6ZknOwdB8D/pBIUX2izRjclq0czFqh9vMNoN9alm 7kdbdpPlINhl2T0ovdvmvGcjVnE2TkzQMsMqWq6qz0aYaMqR6hhZ/B/45cU3DtIyKROg G+o6V2wMQPTgnrgwzcZL32fiPOdyRat3FLY87MD2Lk6AvS5QNvTHDE+FUxzLyJ7V5UPv uHxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="L/tTBCQl"; 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-158289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158289-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id mf22-20020a170906cb9600b00a51d3658a7asi9471932ejb.594.2024.04.25.02.25.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 02:25:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="L/tTBCQl"; 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-158289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158289-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 am.mirrors.kernel.org (Postfix) with ESMTPS id F3D591F21BEC for ; Thu, 25 Apr 2024 09:25:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F07FB127B4D; Thu, 25 Apr 2024 09:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="L/tTBCQl" Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (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 B4DF81272AF for ; Thu, 25 Apr 2024 09:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714036925; cv=none; b=jB/lEEJt8kesvCbKIJ/ZDFnHdnT+pVoV1qC3yIDnv1Nd8YW7F1Y64mlxf+jki//8KE+WwWwTcsynPlaVJBjLY8edM0TW6rVXqKwJpz+LqKiI0QulNbrO8A+lNibPFYIBBWeQQ8DSZnqahI/bp/LTNUVC3gen/VegM25ZRsZwWAY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714036925; c=relaxed/simple; bh=4PuvvSrgrUY9QfAUKjuGoS3AnOhcCgoDp78Xl1PJe2w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=feAnfZSm92AvizzU7SLQwLICr2gv+JG6T3hrlX+1d9ocnrvf4u7OFckGILk/Af1BLuugFcoqJo3oQp3hFy0mrgIu8qFYVkSpD4W8+aTFck319gE+/AQvx6+Le2hlsFRTzOplTG4pZx19BZaw2dEePClzgBn2Rawaued857Bhoyk= 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=L/tTBCQl; arc=none smtp.client-ip=95.215.58.183 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=1714036921; 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: in-reply-to:in-reply-to:references:references; bh=DFTiIIshBt3nHGS/4A3nNNzLGmWXkp5ut7bbz0K7Lek=; b=L/tTBCQlgNyM6irTUBCMN/Y6PXJQjRQC9n0W0NtMa5LHG8Pb7sNC5gdYslPPrMV9B8hSLr CXs4h4OEagpy0KKe2NFnI48BIh9Q+G7CaZDjNkwO12RmU4ujfR6Ct7hiZsGa1rWSc3iLsi kJlISbN0kcONOTC1OgGyL3RaLBNsJFw= From: George Guo To: mark.rutland@arm.com Cc: ardb@kernel.org, catalin.marinas@arm.com, dongtai.guo@linux.dev, guodongtai@kylinos.cn, jbaron@akamai.com, jpoimboe@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, peterz@infradead.org, rostedt@goodmis.org, will@kernel.org Subject: [PATCH v2 1/1] arm64: simplify arch_static_branch/_jump function Date: Thu, 25 Apr 2024 17:21:18 +0800 Message-Id: <20240425092118.2924369-2-dongtai.guo@linux.dev> In-Reply-To: <20240425092118.2924369-1-dongtai.guo@linux.dev> References: <20240425092118.2924369-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