Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp49034lqm; Tue, 30 Apr 2024 12:19:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXu92edNybm9TZUFI0K9NjEtq0oLyc23RghPTg/YoKYD4Uy8sPnfPG+U0feqEU0RjeXXGAMZ4F8eZjsV5A2w2s/2PNm9z5GUesU73Jcog== X-Google-Smtp-Source: AGHT+IEewQtyFOsyNnznnf90bgIkoiz1Rhq944LNmbZ0CC2i7JfoWV0K31J2FwOSs8pkjB3Pq/MJ X-Received: by 2002:ac8:5d0e:0:b0:43a:f948:30ae with SMTP id f14-20020ac85d0e000000b0043af94830aemr289656qtx.27.1714504770389; Tue, 30 Apr 2024 12:19:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714504770; cv=pass; d=google.com; s=arc-20160816; b=GYHoek5nWP+tljLBRVV3Xvp7h8lL/hFZwgbXw1FMKc893sUBbBWJmmdjgv/PPDuHqM 0PZuOnQ1FURHu9j4KD/0id9uGbTIwHBHqPEfRBa9X1SPmEH+Abw9yTBHvOfq3Tl8XJkp kgFzeg1cxEQEqACbpglL7ryiHVgtBuglD1/n1R6Nf8fAuri++NVvAKl49CBm5CZujlAc hwy3SmE8SqhLZOIV0qaFMNYnfUZ3a7/Ye+fVABhfkHPmY3MoMVxjETDGigzbkVie3WT0 DT63bScdGn3crS2QlpFLz1SVm3RgPYtZhi80f/mDiVsqzgRB+K0hMpj31zvGgpHkndqg sfqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=F8uFehdUx8z7xRSqATk4C9fttlOvgfKnCVngjCGKN8k=; fh=0T2jhwlFZpCJxc91rmlE9Rq1Ox7NGaav34Ksn1CiztE=; b=Lpb/s++aFD5DGq7L9vT8XBZdUivebDBsI1QT/Eg7bTxB9mYmFnANX8E13bG/Zm82y6 5SFGfO87IdajbDbRroVOibIuCnWyQ5CCuGqLQGW/llCLpSCpyp2skhcv51LFfx+3M7ql rHlRy79ScGJk8MT7gd/jTAt0tdNMTiH511K8671gVbMjHShBvdDllYyoyYUxR1mOnZui 0mo0g66leMHYJmigVIMHVXkVZzekv83QE0KMt1AN/HtE1Hvb8nuXUisWN5jXl2Ecy6Af yVdCtINRSbWNvUmBlK1Ju6esPkloUkhqBZaLksCKJilPlg9QGAZAT7JA7H/YBFFlToOT kORg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YizhJOof; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-164632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u9-20020ac858c9000000b0043af12802afsi4947732qta.153.2024.04.30.12.19.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 12:19:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YizhJOof; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-164632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EE6511C22797 for ; Tue, 30 Apr 2024 19:19:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2148A199E8C; Tue, 30 Apr 2024 19:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YizhJOof" Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) (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 AA515194C8B; Tue, 30 Apr 2024 19:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714504762; cv=none; b=rKR3iPPDvBM95F74345poEaZn0XdBBOyJDDibNyBIkgBiTHjJc/wfoSOuhfNB9u/JA7iTkLPq1w/mN0rbe/+p/wSAJtU8THDpelOHc+FkVo8Eq3RIMqMNaQaomI22e8gVaR3wmY8XjpNNIADJmX9yHDnmyQYSpTeO2iZrwAmTfg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714504762; c=relaxed/simple; bh=z+qde+gt9C/fcxAsuzbK9YjKXb2Ca0riTnpbLCOoQzo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CwVw5ATWJMU65jx5nqy/X735XQiKvdfP5t0rJkFSQwtApOUtLpxwkWQDrSEzGnYFlcLSzjhSklUq4Tx68bEjn4AxWQWKbTpka7BNVYW4UZhD5Wslmzzs5QYHfBqw6/fnTZP4NYlxSGgGg0XEgw739vdFZrObdgfz+3w65NC+jJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YizhJOof; arc=none smtp.client-ip=209.85.208.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f68.google.com with SMTP id 4fb4d7f45d1cf-571be483ccaso7460865a12.2; Tue, 30 Apr 2024 12:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714504759; x=1715109559; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=F8uFehdUx8z7xRSqATk4C9fttlOvgfKnCVngjCGKN8k=; b=YizhJOofhd1KBfqNBW50da+471do1Uwd5VZO8btYFTUfx7h0QAIfXLUOB0Clf19YSH H9L1ZXwTzLCOk4H3TS+YnK88ca0jdeHjgxuqGPdhM1htQn7pQsuahb16/OMIJlKBXkAh fPxd0JYRv2oXOwS5saJW7HDogeAYQ9AQXkBWXEZiKPHjZvN9SD8HT19xwd94ZaGUXbp5 G3JQvI67kTDZaNKcq16GpJ4hsyUkK244NvB9hl4vVEnFkwwhYz4drfFDE3cTAlZd4wsV w9L/5YulxkWC811jjt5//VdTz8U6PAgeZInEeykRNsrR5xEqWxGGWYBirGsCd0RzvTTC CG1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714504759; x=1715109559; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F8uFehdUx8z7xRSqATk4C9fttlOvgfKnCVngjCGKN8k=; b=MXDuFXUXu3xrim972B3mwRguGHWM6V7TGDO9CHCU5OJ3zVbq5jByxctTbg2olwCKcJ O4iWAkBYHIReOlcfZv0GBcbVQKAr/6mlCFmkP8SqgSh6oMqpGyzwXaAdIMRfx56hIGWV afViFzXwL9+fwg1c+hliw+/v921HaKYg+UluBiBaSw57f7wgIhSq7U3mRGpmGw4kfQxn yXPbuBk+9+LVUgbiAqZcyxzOKRRu6ZNIpdlEqfm0Mg451fMai1FlKIGVSiprbhvzbvhS td1+og9U8XqV0hXV8AgGAzsKlVFWYl8iZg2lTjuO25WbOD2Ho5Nal0330+KyhqbUt2G/ zptQ== X-Forwarded-Encrypted: i=1; AJvYcCVmv2IVJ6PaaUln/Dks7rc6+fDoJcORYh7yG68w+G192YOBsu/3JKhQ/bGPDL+VafLjDjPlF5cBlrfaqskd9iKmVlhNjMj1QWo7fDhe9A9kfU4eLYKYOoLNb2a9KBjd+Qdu X-Gm-Message-State: AOJu0Yza3cJLf/DS84XbrhGWR/K5vsT6Pdi0X5ryBN5Fe7erJVo2rMuC +ggsk6ZTaBstx/F9VNAYqUOP+cBJvL40k0ugQaVxJwE3Wi8AlU8GPTvEEKnuUB0TZGPRvkpYnqg cYNlGGJjkV8UFJG+3E0Fshv2/IbM= X-Received: by 2002:a50:f613:0:b0:572:47be:be36 with SMTP id c19-20020a50f613000000b0057247bebe36mr182665edn.0.1714504758705; Tue, 30 Apr 2024 12:19:18 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240430175834.33152-1-puranjay@kernel.org> <20240430175834.33152-3-puranjay@kernel.org> In-Reply-To: <20240430175834.33152-3-puranjay@kernel.org> From: Kumar Kartikeya Dwivedi Date: Tue, 30 Apr 2024 21:18:42 +0200 Message-ID: Subject: Re: [PATCH bpf-next v2 2/2] riscv, bpf: inline bpf_get_smp_processor_id() To: Puranjay Mohan Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Paul Walmsley , Palmer Dabbelt , Albert Ou , bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Pu Lehui , puranjay12@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 30 Apr 2024 at 20:00, Puranjay Mohan wrote: > > Inline the calls to bpf_get_smp_processor_id() in the riscv bpf jit. > > RISCV saves the pointer to the CPU's task_struct in the TP (thread > pointer) register. This makes it trivial to get the CPU's processor id. > As thread_info is the first member of task_struct, we can read the > processor id from TP + offsetof(struct thread_info, cpu). > > RISCV64 JIT output for `call bpf_get_smp_processor_id` > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D > > Before After > -------- ------- > > auipc t1,0x848c ld a5,32(tp) > jalr 604(t1) > mv a5,a0 > > Benchmark using [1] on Qemu. > > ./benchs/run_bench_trigger.sh glob-arr-inc arr-inc hash-inc > > +---------------+------------------+------------------+--------------+ > | Name | Before | After | % change | > |---------------+------------------+------------------+--------------| > | glob-arr-inc | 1.077 =C2=B1 0.006M/s | 1.336 =C2=B1 0.010M/s | + 24.= 04% | > | arr-inc | 1.078 =C2=B1 0.002M/s | 1.332 =C2=B1 0.015M/s | + 23.= 56% | > | hash-inc | 0.494 =C2=B1 0.004M/s | 0.653 =C2=B1 0.001M/s | + 32.= 18% | > +---------------+------------------+------------------+--------------+ > > NOTE: This benchmark includes changes from this patch and the previous > patch that implemented the per-cpu insn. > > [1] https://github.com/anakryiko/linux/commit/8dec900975ef > > Signed-off-by: Puranjay Mohan > --- For non-riscv bits (& fwiw): Acked-by: Kumar Kartikeya Dwivedi