From patchwork Wed Oct 25 05:31:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "wuqiang.matt" X-Patchwork-Id: 157821 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2382290vqx; Tue, 24 Oct 2023 22:32:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEW7mOE0++eEQd0z3wiv+P+e6Qvrxd18EIxNDNq6dxLsI3lv48gYZ3svPAeeUAKS9d+dsu1 X-Received: by 2002:a05:620a:430f:b0:774:1d7f:2730 with SMTP id u15-20020a05620a430f00b007741d7f2730mr14811203qko.46.1698211946505; Tue, 24 Oct 2023 22:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698211946; cv=none; d=google.com; s=arc-20160816; b=sJHrgpTsdX80Z/FTeI1Obq67cPD2JslMUnOSwO9tzQsgl3H//Zpx7K7PVQh0KoBI+k WMDQQ++2j2JkorBDoBN1++Lo56RqLpFLp09kNB/WfTm+whD8+Rr/Bn08/vOYNoHtRsfE F7GcXl46Gs6+5YYPYtZeoBYTDybXFhTX8j1C/HUA36gIPUkuYJ4pV1v3wDtmu/4+mfsp pzhKIiKFA0wbQd6nbTD2qqOKLDv02rI8uRiHpYPCjed7tptEef77wkdc43V1TV5Z+YyY u3/qrn040Dgt7EExBxTE9ORHb1yKrDKUTbWYSbWNetntmTpvzkeTXwYIc4/y7OAgPYeK ILUA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ktOpyXH4xJvQjTjiv4myd5jeNbk19v5L3mPK+5WZ6SE=; fh=IpZUYbsqKid0r4pbePo9OTESEiKTs4Y7HhR29dJG614=; b=gA8kjhITp/2bEVGM0QNE2xrxYTEC1qFgLA3FnieI6CAxV3Zf24+yW+YmknGoyqSbwP GK4un3AC6qZbsIp9BB5n/CQjc9aPB1ag9pVa++EdADUz86shB1Hcv5uVH+U0amhU2eKs nurwzhQ4/CySrXNJzsmxcGZBf/TvlFmTyXiIIImGxafRNSce8FSGPD6AiRrMt1+WOS4R HobGhFP/HIwAaeB3Jv0yb2mUcPV2Bac3Du2LNo0V36z7hBe2OYld1YSaATtZ7lB2Ec55 HTjlHFrpI0HHiIxtijk9QV6iuaHORDt1Yc2DBBDYxg5Uzsl0tTiXNVhTU9qiGUxx3UFj Tirw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=NU7pgaOd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id e68-20020a255047000000b00d9ccc92adf8si9724807ybb.96.2023.10.24.22.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:32:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=NU7pgaOd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0A78B806E3C8; Tue, 24 Oct 2023 22:32:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbjJYFcJ (ORCPT + 26 others); Wed, 25 Oct 2023 01:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjJYFcH (ORCPT ); Wed, 25 Oct 2023 01:32:07 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2DBC128 for ; Tue, 24 Oct 2023 22:31:43 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1ca052ec63bso45418895ad.1 for ; Tue, 24 Oct 2023 22:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1698211903; x=1698816703; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ktOpyXH4xJvQjTjiv4myd5jeNbk19v5L3mPK+5WZ6SE=; b=NU7pgaOdmQtFzDcIrlAIpOrOJoOsBrWSARf6YtfdENDvS7C4ZK7Y2f487st1NvLZDZ 8DifvchcrofAMOJYA0GIQf1Ve4gF/jGVRBj75oE641NdFxJYK/iPCpMgBz2aHu5200QD Y3gD1n9kakT92wbc04GZ04o1I7iDLsUczJrCBUV/4Gv/Iv+eW6wB/reJZ4Ln2q+e4g4r rgIfegf6/PYCVUvkFAXSyaVfQsBzpfvFgqbTvlUmPLCWwg6bBLFHylyfNfKsNo+Hy8L4 Mg/h2vMG6VEeZDJbjGb/1fZw+i22RqEYL+QiPjkEPNBLi5BMyLA1eedvaLJ+8grzf0sj Upjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698211903; x=1698816703; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ktOpyXH4xJvQjTjiv4myd5jeNbk19v5L3mPK+5WZ6SE=; b=nOK6Eniae8kUW4nj6O+dda93MBTxVV3cYxT2bLjqxPevWzwTewphABK81aZtGY1ER3 fOdFaHMsQoGWVcimpVTrEGbg6mqpyInhsNvU3Mi6KC7kKOm5LJV0hr76fn/Eq6wehWMy oMxvYHw9rY2ZXSBxFcgM7Vkul0QdXNX+yf0DY352nF+JHr7xoy7D3vfXzUBEc+zaGMyx +XZxPWHNA1Sm3Pl5+Pq+7PocjcgJKMe62h3h3hMUeQxWxtxg4TQLYEUd4J4ZQBd2v00e Ia+cpTpFP/a886jOXjIA/XEKMOjRc+VsxGLzR/Kn5MDBr37+rowkgbIkLVQs/4AJWeBO pb9A== X-Gm-Message-State: AOJu0Yzf6la89x5HF84CzPZunqn4BFh49cxi+MhRgDCPgplFDiEXXFeu cYNPWZ00+IKERUF6KA8HfzxeiQ== X-Received: by 2002:a17:902:e5d0:b0:1bd:d911:2a85 with SMTP id u16-20020a170902e5d000b001bdd9112a85mr16244605plf.12.1698211903253; Tue, 24 Oct 2023 22:31:43 -0700 (PDT) Received: from devz1.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id 5-20020a170902c24500b001bc2831e1a9sm8278906plg.90.2023.10.24.22.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 22:31:42 -0700 (PDT) From: "wuqiang.matt" To: linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org, davem@davemloft.net, anil.s.keshavamurthy@intel.com, naveen.n.rao@linux.ibm.com, rostedt@goodmis.org, peterz@infradead.org, akpm@linux-foundation.org, sander@svanheule.net, ebiggers@google.com, dan.j.williams@intel.com, jpoimboe@kernel.org Cc: linux-kernel@vger.kernel.org, lkp@intel.com, mattwu@163.com, "wuqiang.matt" Subject: [PATCH] lib,kprobes: objpool_try_add_slot merged into objpool_push Date: Wed, 25 Oct 2023 13:31:33 +0800 Message-Id: <20231025053133.343923-1-wuqiang.matt@bytedance.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 24 Oct 2023 22:32:24 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780704289612026807 X-GMAIL-MSGID: 1780704289612026807 After several rounds of objpool improvements the existence of inline function objpool_try_add_slot is not appropriate any more: 1) push can only happen on local cpu node, the cpu param of objpool_try_add_slot is misleading 2) objpool_push is only a wrapper of objpool_try_add_slot, with the original loop of all cpu nodes removed Signed-off-by: wuqiang.matt --- lib/objpool.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/objpool.c b/lib/objpool.c index a032701beccb..7474a3a60cad 100644 --- a/lib/objpool.c +++ b/lib/objpool.c @@ -152,13 +152,17 @@ int objpool_init(struct objpool_head *pool, int nr_objs, int object_size, } EXPORT_SYMBOL_GPL(objpool_init); -/* adding object to slot, abort if the slot was already full */ -static inline int -objpool_try_add_slot(void *obj, struct objpool_head *pool, int cpu) +/* reclaim an object to object pool */ +int objpool_push(void *obj, struct objpool_head *pool) { - struct objpool_slot *slot = pool->cpu_slots[cpu]; + struct objpool_slot *slot; uint32_t head, tail; + unsigned long flags; + + /* disable local irq to avoid preemption & interruption */ + raw_local_irq_save(flags); + slot = pool->cpu_slots[raw_smp_processor_id()]; /* loading tail and head as a local snapshot, tail first */ tail = READ_ONCE(slot->tail); @@ -173,21 +177,9 @@ objpool_try_add_slot(void *obj, struct objpool_head *pool, int cpu) /* update sequence to make this obj available for pop() */ smp_store_release(&slot->last, tail + 1); - return 0; -} - -/* reclaim an object to object pool */ -int objpool_push(void *obj, struct objpool_head *pool) -{ - unsigned long flags; - int rc; - - /* disable local irq to avoid preemption & interruption */ - raw_local_irq_save(flags); - rc = objpool_try_add_slot(obj, pool, raw_smp_processor_id()); raw_local_irq_restore(flags); - return rc; + return 0; } EXPORT_SYMBOL_GPL(objpool_push);