Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1797287lqo; Sat, 18 May 2024 22:02:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQ5zdFr2DUmwiLxoYmS6H8HijCDmtjRn82h0hBQi6pGK8pWzjSfhQfKyY3gqg57nD1olhNTbYZsqn0I7dRhX/OrsKLTPf/BvSv8Dd6TA== X-Google-Smtp-Source: AGHT+IFO7mtPreZMwSgtIBOCloKKp4vHX6mWkNButzRDOb5wSevRdz8FSk7y6/O9sbziA4Nb/Yja X-Received: by 2002:a05:6a21:2785:b0:1af:d1f0:b34e with SMTP id adf61e73a8af0-1afde0a9c34mr24064020637.7.1716094928062; Sat, 18 May 2024 22:02:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716094928; cv=pass; d=google.com; s=arc-20160816; b=ufgZS7SgGmnsaJYg1C0k9ut74LJfFGiDHzRPqTQvtYjqoJyg/MfZKmlXUqGMnRL0od PlC6a/d/XNf132jhxM1x+McgZpNdFRvZmYjcVPsjknBvbPOxjWdh5+JgTZeFFc4Tq/E5 /lj/LJ3xuFpJ2Mr0Cxg9Y1A8hHZqVcQl8iEs7vFLClT/ai+aXrkHR4Wubtercl64tHQb P1N4/gfo5aZtvxPd7vNg/6eS7C/SdHFDeJn7VC0eHvvoD9eCiUoxLGPQx17Bk/cfOZmB iRfL9DkN+m8dLL9IdtsIluyurw1AO9yfW1fZjKclCC0kOCDaO1nDL4Be1Ve8Y1rqbTj7 MPJQ== 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=B9n0pFr0LXk81OyNb3wFTHARjGpIR+6+o9Lqlf0XNDc=; fh=M6YEhU8YJeo9C1oIi9o2G0SZY1YXgjKsYBioz6s/Gxw=; b=jCSgqvBs3hPYdSWsTkA6Ju31hTp1uANZ6n3UeJDU8LGbPOHDB9kBi/0M5mUqRM5P9g nnso/k/yEnLiJefMgrlCHMoXWjOwMzO8RnsFbV4Oqd3uuFKT8qFDmA40KhXz6lKXMGbY OtXzXYrzUdXv0eiH6je5QtQLUsJWJ//ZUk1wzqWM4AXnfKWkxBxZNBUYlYfMpSTLH8tl nguyS+YN6t7IZylSoF1Z6AzV64ns5eupFD79C02iBZhOTYMyyCq9W05Z+Ne8zUWL4FhG LoBGA/zDHlWrEZ007YC5a1yI5UzM4r7gAlxyUTBQ8q5YTmvDOWJRgRnuIln/w+J3DGMo 0RDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i9a8la5A; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-183024-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183024-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b6288655f7si21232653a91.2.2024.05.18.22.02.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 22:02:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183024-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i9a8la5A; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-183024-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183024-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9A9E02816F7 for ; Sun, 19 May 2024 05:02:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C32AF9D6; Sun, 19 May 2024 05:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i9a8la5A" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 6624C4C7D; Sun, 19 May 2024 05:01:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716094919; cv=none; b=TEdOmZJRqDGjF1DoGmDSr/AmStbdX68yFCjgjt2H/eEBgLP90k2x7v6NP6qiDsuwjPXav1FLH3Gk6gbsaIg82SnBVeL+3A4o//luzer+vCcvwpITHl5xpioLxotmg/bSwwFIl0tKF7fOPB/gJCyw9CngGaFkdtDfaRvG9yE+K/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716094919; c=relaxed/simple; bh=JOXyQnL/Rd4T3+2ptcou/ugUznzFoHrhbhcuHxJtPgI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JxeYRGz3ErzkDRH5hB5qtivOs6GZ30zEuIYK5ibZCTqB+usQCthP9CowJQkByQNrzLtGUKb5oHL/CfxIUFe7grjMJZS3KtnicBXnJWjnr9DoG4oK0ibCS9TpJkUbLPJLP9qSNZRLS7LOsLBBAD65xzSLHwjB1JGnepkLynbx8uI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=i9a8la5A; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716094918; x=1747630918; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=JOXyQnL/Rd4T3+2ptcou/ugUznzFoHrhbhcuHxJtPgI=; b=i9a8la5AyLwCoYrleumy0KiRFJ5OZi2hcnYMLCPcUi4dvYEa0YxJZBPw uNk5govzlfm+fU7jiZaYh+1K3TEZn0vBcSHgoY2KatEkOO592YxYTVB/h dTslMkqizUJ3C9G3xtQ5o7+a6uxFYRn9TP/fOiQ0BXkAiWYtmlfavN5w5 fKmY/LgKSNtGvP0WmztLaxc9fRty+bViLPYzsgn4StHukOozqIny7xCGh JYwwHK7TwPT7jSfwEdo3MvEQAHr+8imn62qLOBKY7Oob8LUUGd0aj29Lo lk/5s/X3xyrHDPpokvaJxA+8UNEFdJ1/wqvGsfgbyjH6EYVrb6HWbigVc Q==; X-CSE-ConnectionGUID: pI4ZDnG2T5e3HTVNifWIDw== X-CSE-MsgGUID: CGqVs2yLTFyDVMcQKPtErw== X-IronPort-AV: E=McAfee;i="6600,9927,11076"; a="12182837" X-IronPort-AV: E=Sophos;i="6.08,172,1712646000"; d="scan'208";a="12182837" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2024 22:01:57 -0700 X-CSE-ConnectionGUID: VMTxTzD9SMe76W4d80VeWw== X-CSE-MsgGUID: Mf1dO27hTISmu4yA6Z9XBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,172,1712646000"; d="scan'208";a="32110053" Received: from xiao-desktop.sh.intel.com ([10.239.46.158]) by fmviesa007.fm.intel.com with ESMTP; 18 May 2024 22:01:51 -0700 From: Xiao Wang To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, luke.r.nels@gmail.com, xi.wang@gmail.com, bjorn@kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, pulehui@huawei.com, haicheng.li@intel.com, Xiao Wang Subject: [PATCH] riscv, bpf: try RVC for reg move within BPF_CMPXCHG JIT Date: Sun, 19 May 2024 13:05:07 +0800 Message-Id: <20240519050507.2217791-1-xiao.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit We could try to emit compressed insn for reg move operation during CMPXCHG JIT, the instruction compression has no impact on the jump offsets of following forward and backward jump instructions. Signed-off-by: Xiao Wang --- arch/riscv/net/bpf_jit_comp64.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c index aac190085472..c134aaec4295 100644 --- a/arch/riscv/net/bpf_jit_comp64.c +++ b/arch/riscv/net/bpf_jit_comp64.c @@ -531,8 +531,10 @@ static void emit_atomic(u8 rd, u8 rs, s16 off, s32 imm, bool is64, /* r0 = atomic_cmpxchg(dst_reg + off16, r0, src_reg); */ case BPF_CMPXCHG: r0 = bpf_to_rv_reg(BPF_REG_0, ctx); - emit(is64 ? rv_addi(RV_REG_T2, r0, 0) : - rv_addiw(RV_REG_T2, r0, 0), ctx); + if (is64) + emit_mv(RV_REG_T2, r0, ctx); + else + emit_addiw(RV_REG_T2, r0, 0, ctx); emit(is64 ? rv_lr_d(r0, 0, rd, 0, 0) : rv_lr_w(r0, 0, rd, 0, 0), ctx); jmp_offset = ninsns_rvoff(8); -- 2.25.1