Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1309367rda; Mon, 23 Oct 2023 08:43:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8kOBGFv2Xk3HQYCBMywKWrSaIKDcuaoB+xVqpDf1Uippw29h71cecyDRGETXNFOH6nnOt X-Received: by 2002:a05:6a20:3d89:b0:17b:2b7e:923a with SMTP id s9-20020a056a203d8900b0017b2b7e923amr7500043pzi.7.1698075804307; Mon, 23 Oct 2023 08:43:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698075804; cv=none; d=google.com; s=arc-20160816; b=lxcw58rBy4ldp3L0mlmMy8C/1dxQCTYmuhmrtrmo5/AcY/PD9jU4Bxc7nN4eG4251f HIprPfVvquYXF0jwK+Tw9ae3flHCWKIGmfQWq9nEXGxIAOCBjoimcGBvKfMlIDLVd326 qzm8d/P4rjDqDIwRg8p9XuNvrqcCD6bgeOM9fiqm9j0/On7AdGSwrMDn+1SEA24SX+Dr r3KmHFCMNej2sXnahJICYoYCZbpXzMzildC7bcNyv4t4TBf2yUoaApjKkvIc2lpSTRPt VOd3mXfqqv9c+Cn5ipDSxAnTdpE3HEUoevxK2Zw5tkuzXXs6ZEcDoevfChKvXo/O8Gzo Q9EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=By8Tgp3RoceN13n3RIi1K9HnpHPti8ZVjHpj5K3kOnY=; fh=F0uMUKjBeTjrpvyECSUYo07Fn+6aSZ9cyiRvSt602i8=; b=CoaEa49fBwH/eKrza8aEYX7BtBOBgA4Z1l047bg+ZuIkJhqXuOipV9PHWuJzpYDjbV cQAs3h1j72z2FyUDnt+HVplJmOpOX+aDvyfcDAt88sPViw3Ncvjj8QCfGc2jmfxEIECG ZVQx1nsLxnUKPyaV0ZJGbiooXQrL7yH53dfMgvhwEK7/f2Obc9iDYRdabUMBU7dBzI5w 6QQu+3zHXgjh/UzfOLAS3schNuePDr5nSWPudGYVEkJvToTTGgRiZtA6OQGZrnlWrhRG fXJbk/Qe6wfvpqQIjklhBb5aUw6NEXViZSme+NtQHaG6M8TF0aQYElnuv7PHrZ35DKkl BHZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id y11-20020a17090a8b0b00b00276c22ca6a4si9073256pjn.147.2023.10.23.08.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 08:43:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 72AAF80628FE; Mon, 23 Oct 2023 08:43:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232646AbjJWPnL (ORCPT + 99 others); Mon, 23 Oct 2023 11:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230519AbjJWPnK (ORCPT ); Mon, 23 Oct 2023 11:43:10 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 806B3BC for ; Mon, 23 Oct 2023 08:43:08 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B555C433C7; Mon, 23 Oct 2023 15:43:06 +0000 (UTC) Date: Mon, 23 Oct 2023 11:43:04 -0400 From: Steven Rostedt To: "wuqiang.matt" Cc: linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org, davem@davemloft.net, anil.s.keshavamurthy@intel.com, naveen.n.rao@linux.ibm.com, peterz@infradead.org, akpm@linux-foundation.org, sander@svanheule.net, ebiggers@google.com, dan.j.williams@intel.com, jpoimboe@kernel.org, linux-kernel@vger.kernel.org, lkp@intel.com, mattwu@163.com Subject: Re: [PATCH v1] lib,kprobes: using try_cmpxchg_local in objpool_push Message-ID: <20231023114304.1bebb327@gandalf.local.home> In-Reply-To: <20231023112452.6290-1-wuqiang.matt@bytedance.com> References: <20231023112452.6290-1-wuqiang.matt@bytedance.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 23 Oct 2023 08:43:21 -0700 (PDT) On Mon, 23 Oct 2023 19:24:52 +0800 "wuqiang.matt" wrote: > The objpool_push can only happen on local cpu node, so only the local > cpu can touch slot->tail and slot->last, which ensures the correctness > of using cmpxchg without lock prefix (using try_cmpxchg_local instead > of try_cmpxchg_acquire). > > Testing with IACA found the lock version of pop/push pair costs 16.46 > cycles and local-push version costs 15.63 cycles. Kretprobe throughput > is improved to 1.019 times of the lock version for x86_64 systems. > > OS: Debian 10 X86_64, Linux 6.6rc6 with freelist > HW: XEON 8336C x 2, 64 cores/128 threads, DDR4 3200MT/s > > 1T 2T 4T 8T 16T > lock: 29909085 59865637 119692073 239750369 478005250 > local: 30297523 60532376 121147338 242598499 484620355 > 32T 48T 64T 96T 128T > lock: 957553042 1435814086 1680872925 2043126796 2165424198 > local: 968526317 1454991286 1861053557 2059530343 2171732306 > > Signed-off-by: wuqiang.matt > --- > lib/objpool.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/objpool.c b/lib/objpool.c > index ce0087f64400..a032701beccb 100644 > --- a/lib/objpool.c > +++ b/lib/objpool.c > @@ -166,7 +166,7 @@ objpool_try_add_slot(void *obj, struct objpool_head *pool, int cpu) > head = READ_ONCE(slot->head); > /* fault caught: something must be wrong */ > WARN_ON_ONCE(tail - head > pool->nr_objs); > - } while (!try_cmpxchg_acquire(&slot->tail, &tail, tail + 1)); > + } while (!try_cmpxchg_local(&slot->tail, &tail, tail + 1)); > > /* now the tail position is reserved for the given obj */ > WRITE_ONCE(slot->entries[tail & slot->mask], obj); I'm good with the change, but I don't like how "cpu" is passed to this function. It currently is only used in one location, which does: rc = objpool_try_add_slot(obj, pool, raw_smp_processor_id()); Which makes this change fine. But there's nothing here to prevent someone for some reason passing another CPU to that function. If we are to make that change, I would be much more comfortable with removing "int cpu" as a parameter to objpool_try_add_slot() and adding: int cpu = raw_smp_processor_id(); Which now shows that this function *only* deals with the current CPU. -- Steve