Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1467489rdg; Sat, 12 Aug 2023 02:25:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTEwOvvD1VyCoJGngVgoH6Lvm6cIoT26eX+KfNwPiOocf/fr9rhyetDnisVK6gNTakocpI X-Received: by 2002:a17:906:3cb2:b0:98e:2b01:ab97 with SMTP id b18-20020a1709063cb200b0098e2b01ab97mr2977569ejh.68.1691832349590; Sat, 12 Aug 2023 02:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691832349; cv=none; d=google.com; s=arc-20160816; b=oisnNphilQagquoxzZkwPUmJZbquq1hp9zzVslFkj3ZLIgrsBD8mOk9OocDZBGZZt6 8KmPQyBK+aWSRK6LY8+FxIYeXUC/KUc+afOYkUQ+wUxb2K5A46W8AyjQJ2A2yvNag/iu 7hNIdx8EfIBezYZvo5CL7U7Izv13yojInB5VqYinPdfq+5cV8cXn0VJigEOkil3hMokC hRlNG5xPhmuIha2iB6qdGOwjMrIFG1pebbuBq3ToaunPySYv/Ms5TmTJ8fiiwTaXhq4d CEFgzWJph0dmhKUgfFQncrdtvCWgJbQYi9pggaJK+HYIfz1bkuFqoD4sScUKZTP0c7gm 1BcA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170906240900b00987b0a5f325si4476783eja.1043.2023.08.12.02.25.24; Sat, 12 Aug 2023 02:25:49 -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 S236396AbjHLIwH (ORCPT + 99 others); Sat, 12 Aug 2023 04:52:07 -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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 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; -- 2.30.GIT