From patchwork Sat Aug 12 08:49:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 134839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1601492vqi; Sat, 12 Aug 2023 01:59:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGz2B8qdKUMlgAMTMxsitq2pse2y6rxifv7erb5U4SckZxAN4u3UWlv2jIE3Q7nGsYE0WaJ X-Received: by 2002:a05:6830:13d1:b0:6bd:a67:8369 with SMTP id e17-20020a05683013d100b006bd0a678369mr5316498otq.13.1691830757475; Sat, 12 Aug 2023 01:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691830757; cv=none; d=google.com; s=arc-20160816; b=QPI0XmOFdYQYqzt81pi9n4gUH1jIBR1QvaUopmN/DPxQ0iyLhvL8CMRgZCA3aPriyg XdBfpH6EZoVk76xAmw9cF+FwfvwbyFGnDqzbS6H0NnzA4Ne7GqC1PkqfenVexuNVWRit W2hkcHCh8eUZEET55cNp6mDz/Oxt3rg5fIRGriU1XKvaABieLeeotjrQLP/RX4vcBshX v+TnG/W+1dVD9g6Hb4t7rlcx1TRH/52w4HTxJWpVBFk4oZhjmUg/g2EcicfFNSs7jhMe I/SQV2+XufrjFGMorEBfZhm8WpufZIFM8KhrvhkQnMaIFg0jYTctzE/dCYO1XVQulOev UJpA== 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:date:subject:cc:to:from; bh=N8Be4pp8IxWg9RTPms5rGRulfaKl8ZbgpFcAOIbTOVk=; fh=yJzUIAXk3G9GFZhd7AEi53Yh6JaeRXiXWLsFmPRnLKo=; b=sVfCutbGUdaYflwz2Beip3HGTyesq0TouK66lFpB6156NOmqoukcP1Ak0U/6e++Vsy k/828WnUmxjm4paxj2oWuTGtqwqys/QmZaNZCXgmqprMLan8DP1/5NpQDSR0ET5jXUqb ezs4xu7XyFGiZFAc2Ro+8v4Xi0BMzZ3Dm/RrkBnQTZOlj7Gs5enqIlhXZVKDk3OTf29g iptDmagzMJo0IOzKgmvNvoHTfvILdUI89iGpsUe9DPzGvoJMTrZcroECe6LhigI0ga5I 4k4T3Az4T4hJf9Cx+1RcrFLqM/61iT7pNjSNTSKX78E0lQ9IqxpYiMY98qbvlh5BCaYQ SXMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a17090332cc00b001bb8c4279f5si4766287plr.148.2023.08.12.01.59.03; Sat, 12 Aug 2023 01:59:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236408AbjHLIwI (ORCPT + 99 others); Sat, 12 Aug 2023 04:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235319AbjHLIwD (ORCPT ); Sat, 12 Aug 2023 04:52:03 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A270271E; Sat, 12 Aug 2023 01:52:06 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RNDrD54zlzTmHx; Sat, 12 Aug 2023 16:50:04 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 12 Aug 2023 16:52:03 +0800 From: Yang Jihong To: , , , , , , , , , , , , , CC: Subject: [RFC v1 05/16] perf kwork: Overwrite original atom in the list when a new atom is pushed. Date: Sat, 12 Aug 2023 08:49:06 +0000 Message-ID: <20230812084917.169338-6-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230812084917.169338-1-yangjihong1@huawei.com> References: <20230812084917.169338-1-yangjihong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774013128673317733 X-GMAIL-MSGID: 1774013128673317733 work_push_atom() supports nesting. Currently, all supported kworks are not nested. A `overwrite` parameter is added to overwrite the original atom in the list. Signed-off-by: Yang Jihong --- tools/perf/builtin-kwork.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 42ea59a957ae..f620911a26a2 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -392,9 +392,10 @@ static int work_push_atom(struct perf_kwork *kwork, struct evsel *evsel, struct perf_sample *sample, struct machine *machine, - struct kwork_work **ret_work) + struct kwork_work **ret_work, + bool overwrite) { - struct kwork_atom *atom, *dst_atom; + struct kwork_atom *atom, *dst_atom, *last_atom; struct kwork_work *work, key; BUG_ON(class->work_init == NULL); @@ -427,6 +428,17 @@ static int work_push_atom(struct perf_kwork *kwork, if (ret_work != NULL) *ret_work = work; + if (overwrite) { + last_atom = list_last_entry_or_null(&work->atom_list[src_type], + struct kwork_atom, list); + if (last_atom) { + atom_del(last_atom); + + kwork->nr_skipped_events[src_type]++; + kwork->nr_skipped_events[KWORK_TRACE_MAX]++; + } + } + list_add_tail(&atom->list, &work->atom_list[src_type]); return 0; @@ -502,7 +514,7 @@ static int report_entry_event(struct perf_kwork *kwork, { return work_push_atom(kwork, class, KWORK_TRACE_ENTRY, KWORK_TRACE_MAX, evsel, sample, - machine, NULL); + machine, NULL, true); } static int report_exit_event(struct perf_kwork *kwork, @@ -557,7 +569,7 @@ static int latency_raise_event(struct perf_kwork *kwork, { return work_push_atom(kwork, class, KWORK_TRACE_RAISE, KWORK_TRACE_MAX, evsel, sample, - machine, NULL); + machine, NULL, true); } static int latency_entry_event(struct perf_kwork *kwork, @@ -716,7 +728,7 @@ static int timehist_raise_event(struct perf_kwork *kwork, { return work_push_atom(kwork, class, KWORK_TRACE_RAISE, KWORK_TRACE_MAX, evsel, sample, - machine, NULL); + machine, NULL, true); } static int timehist_entry_event(struct perf_kwork *kwork, @@ -730,7 +742,7 @@ static int timehist_entry_event(struct perf_kwork *kwork, ret = work_push_atom(kwork, class, KWORK_TRACE_ENTRY, KWORK_TRACE_RAISE, evsel, sample, - machine, &work); + machine, &work, true); if (ret) return ret;