From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E271A154435 for ; Fri, 27 Dec 2024 09:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735291221; cv=none; b=AjDZkq96l/lL9xSG42UxywrmXTxRwuqoeBAZ6CXRxg5SqAdBbCpvfDJJurT6+wJbm7R4zELZA3qjQtpQwdfu0ptuG2cFerx5RKauwIsXpKsxs7o8Yh/D8XDnwPCuzf5QB/YlAELvKiyBMtl+22H0uQc2gPfNyrlOtqiXvXgFXIg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735291221; c=relaxed/simple; bh=Y3fh0ce3Zu8u22azo60MsnTDQj8MqDTK+3uZANqZ8Ms=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BvWwZ9EAknDDrhBMHjYAhVkj7xKH68keE5p3v4F6CcCZitRdX5g+aJzi1mbMkO4lz0vkB/Roe6Ugc2ut7pTfIKS4Jiu1j0m7w/ofSG8LjD6nwyVIaKac+hJJxz9KFPG4O+C5LiggAN1r5cSPHRLK4lM+utvY+FJcCOQbON07poI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=V8Y6BiNL; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="V8Y6BiNL" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-219f6ca9a81so564945ad.1 for ; Fri, 27 Dec 2024 01:20:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1735291218; x=1735896018; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jibWnOynvj6Tts5K4/dFPRmc8WUjCemc/7h1jj7PBSk=; b=V8Y6BiNLskci145oVKqgf01EbyDFNYP8jLAPiiHXSRQEPK/UMagz41Q4WGS+R73zk3 Wm1rBTi3vTcvCmjQe2aGI4hZKytA4xZtO5AVUZiPxHPbNnehYNdYtkfI8nqi7OP1RG2n aifkFbkyebgH0/vCPariSvLnn4bLIi2MV9pwceo5hhH5VUMbztOzAfDqxYc0AC0QE0eY BUEGmiId8uQNctWcTHrQsAuM/Os+KjvI4E4tOyvDoT49RBOw55rHYmbldkIpEfX7muy0 oADelPhBq75h0E239PcIyfU96pHbmHe3w4updSs94qWlsnmez5Hf5hPOQ8/e0S5JDcNg ZubA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735291218; x=1735896018; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jibWnOynvj6Tts5K4/dFPRmc8WUjCemc/7h1jj7PBSk=; b=D5Dq3d9a47e97SMmqj7P2prx12BL0Q9Uzzd8HknX0jNlWgAJGcD8s7ukYM4xknWrGL BSGmIF5CQjlsr0A/5le4a5wu8itqoLGSDog/Ouh+pkbigXOVH7ilB4TOt1LToookvWT2 pNTm4+02hPlxkeUTlhwEYGLT7QkBH0fgyikGtbrCcU03p1ObvLIPckICojz1eVj52GTu CmlvAYVFBKiOpq1LLrGhZYX7MZ8Fv534WuDl4aCf1NPuj6ECzr8XuSkQQdJr+mT4LPTx txU81E55C5PmaTrYn7JQJykETFVqSHxlc7Hj/ig2oS45UPd1B9ygzhQQ0UzTf84yYaVH c5VA== X-Forwarded-Encrypted: i=1; AJvYcCVM7+/CiB1croECD9+K9gNVkXVIiE0/mAIUVKnLFTXXP3rtkQ13Y9IlSFW9kQon0LaQB9VFYwfAM7WLIB0=@vger.kernel.org X-Gm-Message-State: AOJu0YxMuYmqLgiNrdci+TZmipaK7CwCurVS+kDgFHXX9Q0128KKQ6ED ZZQzkAexVDAiZ1lxjcerPNEKUMQ9JCNdB3/k1OvkMhT1OE6cz+oAc1Agbmxy5A== X-Gm-Gg: ASbGncvKDEBFJgwvl4bN7qHDb51vkF+ryEWJ6jxuYHUCItnF1MU4lsT8EJYjw4Z8BFk YHkUgJNCd5La7avqiEIXxUICSYklicB7SWYb4xHzWKszzVL9auYHEcYspLj3vcHQYWt1p7cxBpG GGis4aCzzE0wzuRlHjZideLjAXBjFMfbUw2+dMvtyqJz+M9+aGZAv0FZqSY6BiEhI/k6QaPGVAw GeaEtZT0Zo3eHZuS2ud+l2SSsH38RwbiVhkQ1Vr86ajw3VuPBaM8yV9wHhqUP6aCfPqvpUUX09J /hr4WbaAwfTVnuvkacg= X-Google-Smtp-Source: AGHT+IEdsphK+fVkaZEclFM1m1g2bZVGWULWpmqPpb2/1q/5JxKqhRKT83SWoqbybovy+11JysBZEw== X-Received: by 2002:a17:902:c407:b0:215:b077:5c21 with SMTP id d9443c01a7336-219e68f5a3fmr11653385ad.26.1735291217912; Fri, 27 Dec 2024 01:20:17 -0800 (PST) Received: from google.com (40.155.125.34.bc.googleusercontent.com. [34.125.155.40]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2ed644d87sm18925077a91.27.2024.12.27.01.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 01:20:16 -0800 (PST) Date: Fri, 27 Dec 2024 09:20:12 +0000 From: Peilin Ye To: Xu Kuohai Cc: bpf@vger.kernel.org, Alexei Starovoitov , Eduard Zingerman , Song Liu , Yonghong Song , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "Paul E. McKenney" , Puranjay Mohan , Catalin Marinas , Will Deacon , Quentin Monnet , Mykola Lysenko , Shuah Khan , Josh Don , Barret Rhoden , Neel Natu , Benjamin Segall , David Vernet , Dave Marchevsky , linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC bpf-next v1 2/4] bpf: Introduce load-acquire and store-release instructions Message-ID: References: <6ca65dc2916dba7490c4fd7a8b727b662138d606.1734742802.git.yepeilin@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Dec 27, 2024 at 12:23:22AM +0000, Peilin Ye wrote: > if (off) { > - emit_a64_mov_i(true, tmp, off, ctx); > - emit(A64_ADD(true, tmp, tmp, ptr), ctx); > - ptr = tmp; > + if (is_addsub_imm(off)) { > + emit(A64_ADD_I(true, ptr, ptr, off), ctx); ~~~ > + } else if (is_addsub_imm(-off)) { > + emit(A64_SUB_I(true, ptr, ptr, -off), ctx); ~~~ No, I must not write to the 'ptr' register here. > + } else { > + emit_a64_mov_i(true, tmp, off, ctx); > + emit(A64_ADD(true, tmp, tmp, ptr), ctx); > + ptr = tmp; > + } > } I will do this instead: --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -658,8 +658,14 @@ static int emit_atomic_load_store(const struct bpf_insn *insn, struct jit_ctx *c ptr = dst; if (off) { - emit_a64_mov_i(true, tmp, off, ctx); - emit(A64_ADD(true, tmp, tmp, ptr), ctx); + if (is_addsub_imm(off)) { + emit(A64_ADD_I(true, tmp, ptr, off), ctx); + } else if (is_addsub_imm(-off)) { + emit(A64_SUB_I(true, tmp, ptr, -off), ctx); + } else { + emit_a64_mov_i(true, tmp, off, ctx); + emit(A64_ADD(true, tmp, tmp, ptr), ctx); + } ptr = tmp; } if (arena) { Thanks, Peilin Ye