Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1379167rdb; Mon, 4 Sep 2023 11:45:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHm/CeqOPM3HGJ8Rwg9EzbQwVdDtd4+LfMfuUpCGi4TjFKBhjHcAfcOjosvgc/Q4FLHVelz X-Received: by 2002:a05:6402:5159:b0:52a:943:9ab5 with SMTP id n25-20020a056402515900b0052a09439ab5mr7868403edd.31.1693853137337; Mon, 04 Sep 2023 11:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693853137; cv=none; d=google.com; s=arc-20160816; b=xhdyKyhvqQXgjrI5ZjtjgFyAyuXN8rw4mE4+oa6KINQa2tx9yuyS1uT1mbUn2dNeDa Ged6LfgT/UBXwexeRmaz6PrExdY5ME3eZfW5qwTX5cJBmO7NTEnXYXC1rgXq5ujWGJdX gQ7hLdZ8M+xujHYLJ2HTSFas+vglv7ItHAolCvKhYUqpG0pjNjaMEiA+GaSWpYYXeenC y24xsXurfhDP6CqLouQj5pKI0q5HHzZmFUFTyD0qbkBjUdZu5mSc7uhIgs3jp9EVIgxG FKvvzAMZ1hlO870tZXVYeTWy6acx914LUpSDzblNdaeUq4mvIAlpSegHOHeGGm9oVd0a 5IYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=TBs7Whlo0Ud/YwBKYj469sEAgp2elBKKZFbILIPAVSQ=; fh=p0K0OHdkH9mhR2ccBEt2gucpCFT1XPQe9rc0G79FFyg=; b=BOMjGFuyHYTQ/dtnK3Z8RhFSS05c1hkjujcDETosRRxaza0lzEkN2Qvn0XOpyS0iuH IxGHJStA3XT7I3jXVWtYakjphjBzBHJw7n1KpIe1/4j9ZYNObpLGKH3di8exqzdABRkf dMnB8iqF+HoTWrzdxBlvOuyVDT2Y/ek3+KW1VB9f77tnlI2VDTAKwZdUPXNkrHkybl2e UTr7KCXWWcTy7LH2zx6Puy8AoG8B8+wE4oZbGjfoviIPjFidkBXgBDnHUG0LwhkpgQGj j7cUuqzUqr9rjXPGD6rVIj6DmY1sX6eVpOH7UzmZq8HVRG8/0guSkAC8AIL+g3ae5D5i VICA== 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 l17-20020a056402345100b00523d212769csi6201139edc.227.2023.09.04.11.45.12; Mon, 04 Sep 2023 11:45:37 -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 S232492AbjIDLqK (ORCPT + 99 others); Mon, 4 Sep 2023 07:46:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352841AbjIDLqJ (ORCPT ); Mon, 4 Sep 2023 07:46:09 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB9E3CC6; Mon, 4 Sep 2023 04:46:05 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RfRZs5m1Hz1DDXx; Mon, 4 Sep 2023 19:42:45 +0800 (CST) Received: from [10.67.111.205] (10.67.111.205) 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.31; Mon, 4 Sep 2023 19:46:03 +0800 Subject: Re: [RFC v1 05/16] perf kwork: Overwrite original atom in the list when a new atom is pushed. To: Ian Rogers CC: , , , , , , , , , , , , References: <20230812084917.169338-1-yangjihong1@huawei.com> <20230812084917.169338-6-yangjihong1@huawei.com> From: Yang Jihong Message-ID: <91cb7bea-3bec-b40c-24a2-be9052a30937@huawei.com> Date: Mon, 4 Sep 2023 19:46:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.111.205] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,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 Hello, On 2023/9/4 12:13, Ian Rogers wrote: > On Sat, Aug 12, 2023 at 1:52 AM Yang Jihong wrote: >> >> 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) > > kerneldoc would be useful. Pushing something seems self-evident but > what does overwrite mean without reading the code? Okay, I'll add comments. > >> { >> - 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); > > nit: for constant arguments it can be useful to add parameter names > which can enable checks like clang-tidy's bugprone argument: > https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html > This would make this: > return work_push_atom(kwork, class, KWORK_TRACE_ENTRY, > KWORK_TRACE_MAX, evsel, sample, > machine, /*ret_work=*/NULL, /*overwite=*/true); > Thanks for your advice, will add parameter names later. Thanks, Yang