Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp126281rwe; Tue, 18 Apr 2023 18:58:39 -0700 (PDT) X-Google-Smtp-Source: AKy350b5yH41lxuk3G8Tcx2n5hdm2o73afZOPpPvON2pRuja0yxvtIkYxjmqz+G7K779fcsMP9Mc X-Received: by 2002:a17:903:188:b0:1a6:bb7b:7a68 with SMTP id z8-20020a170903018800b001a6bb7b7a68mr4433162plg.37.1681869518853; Tue, 18 Apr 2023 18:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681869518; cv=none; d=google.com; s=arc-20160816; b=JOo8X66RUoFiAI/nftSRQvmkecUlMPs2d7vLZ10+ukNiAjxyT0WWnJA1OzX4bSYvev RMCOxTohKB9+eF1V9wnM/TRXlfFOTWfRbS4DI2GctND0s4I7IXkDpKTChAim5Q8abPf6 fcyGhyAM6TokN7O/IjFX98D76t2rWquWr5NTpBrN5E0coyZY+1vbmemAZtgSjld50llV +95uNLRyRWDhu9Cac23936eTchqSqsrtGVMgoSP2r67+oKRBh6XVBKP3bTigTw8tGZ1P VCAgwbgdISMsv/N8jJ5JK00tDmcaZvBpGDAuSJ+/ad34rD1DCVhu7RpoQ1EW5257rDBp RdrQ== 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=vSQAVPiYtCIQs8cb9Stp011+pmhESpVmIkROIIS4+3A=; b=FeMF+3US+73781aVAc71Z6iHOFRwGUY0FJXVJCS6WHAHsTlnPp3mKCR5id5gCRo7O5 yntFi9tdhfEkefTmcrltVvDx2eZ0aWBjX9IDwONJecjxxKQYpgvOCan4akHDYQWNGu5I z7G+RIIcI/X5Mc2wU963l9Kw4uTtDxRYfGlUSmeqSOid1CF4pVbDhWpx/4uqZwOBTa0i 0dL722sCmTAy7MQgELZ2+LvLOo1F81PJb6UmAa53k7Zv5JfEBcOQFpoZWfP4aUribsIz Dc7UqbBaAigWyIQ1O64bjlwmzCo7R40Zbu7UOiLAeRK+yrBOnhujiv/v/8SREnCE0hPB VfAA== 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 b9-20020a170902d50900b001a6632368ecsi16126189plg.503.2023.04.18.18.58.27; Tue, 18 Apr 2023 18:58:38 -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 S231620AbjDSBrK (ORCPT + 99 others); Tue, 18 Apr 2023 21:47:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230153AbjDSBrJ (ORCPT ); Tue, 18 Apr 2023 21:47:09 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 346327AB9; Tue, 18 Apr 2023 18:47:08 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [7.193.23.202]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Q1NpW3cNNzSswL; Wed, 19 Apr 2023 09:42:59 +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.23; Wed, 19 Apr 2023 09:47:05 +0800 Subject: Re: [PATCH] perf/core: Fix perf_sample_data not properly initialized for different swevents in perf_tp_event() To: Peter Zijlstra CC: , , , , , , , , , References: <20230412095240.181516-1-yangjihong1@huawei.com> <20230417114512.GK83892@hirez.programming.kicks-ass.net> <15805714-27c0-b8ff-143a-8f768704a673@huawei.com> <20230418102545.GX4253@hirez.programming.kicks-ass.net> From: Yang Jihong Message-ID: Date: Wed, 19 Apr 2023 09:47:04 +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: <20230418102545.GX4253@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.111.205] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600003.china.huawei.com (7.193.23.202) X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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/4/18 18:25, Peter Zijlstra wrote: > On Tue, Apr 18, 2023 at 09:35:23AM +0800, Yang Jihong wrote: > >>> I'm thinking perhaps those flags that update ->dyn_size are the problem? >>> At the same time, Should you not also then clear dyn_size? > >> Yes, according to the code, dyn_size should also be cleared. >> Maybe we need to change it to the following, which would be more >> appropriate? >> >> --- a/kernel/events/core.c >> +++ b/kernel/events/core.c >> @@ -10144,14 +10144,14 @@ void perf_tp_event(u16 event_type, u64 count, void >> *record, int entry_size, >> }, >> }; >> >> - perf_sample_data_init(&data, 0, 0); >> - perf_sample_save_raw_data(&data, &raw); >> - >> perf_trace_buf_update(record, event_type); >> >> hlist_for_each_entry_rcu(event, head, hlist_entry) { >> - if (perf_tp_event_match(event, &data, regs)) >> + if (perf_tp_event_match(event, &data, regs)) { >> + perf_sample_data_init(&data, 0, 0); >> + perf_sample_save_raw_data(&data, &raw); >> perf_swevent_event(event, count, &data, regs); >> + } >> } > > That is certainly the safe option. I just went through the list and > while there's certainly a number of options we'll recompute for naught, > most of them are indeed either dyn_size or event specific :/ > > So yeah, please send the above as v2. > OK, will send v2 according to above fix solution. Thanks, Yang.