Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2123290rwb; Fri, 2 Dec 2022 05:57:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf4C5IHlc56Dpjnd07tjFdWyc9k6lqAIqUrSo61oJDBBD2dhyF9k57e8f4g/MkiV8RUqXTGc X-Received: by 2002:a05:6402:10d1:b0:467:7508:89ca with SMTP id p17-20020a05640210d100b00467750889camr48544295edu.284.1669989444655; Fri, 02 Dec 2022 05:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669989444; cv=none; d=google.com; s=arc-20160816; b=toYzX4LNjL+PIJ3TSHiFz6AsjfoFLsOupulOOk8UsAc0f02L4ipP6+h5E9V0L94Ptu Y+NBJ33zJm3BQKGO6+I93HxxNhk66yqtlqWpQEJ93ev0fG43sfC+B2tAoWDm+YaSesdQ fX8QufnI9QzwxMwA5zeL1grOZsuwL7KNC81WJ4Tj3M74PfGtxxDZ+PClNwl+eRTqxoJ7 gHTa9TnNEk/FhWK+38NOSL7S97JcSN4TqzSwdVUZtmL/JSYQvUcoYpML4JLo3Z9Tjyug FoBcWCXAu4LSqiNf2uNWJBFoJ8vteFnK7IRNFCovtlmvOzNb87gv3b26vXKpALe3yLPi fiqA== 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:subject:cc:to:from:date; bh=j++vXfDAGVY07wM1dTyo2EMSRsXKxtJsGmrZ8/13+yw=; b=WBI2WQ1JnJCeeUATc/maTsnJDjMezLIb71FErKD3EfUdwP6l/jPFkTXK+ozg4phzG6 D2YSJWpY8mI36PIvNa5cy7V50i/HI1sXIYJAN017wlp/wfd9/FxCKiTMcReCYVIrsVZZ N9QE1+nU/C8wh9CQV9tZA9uS2SwVK0eVn/1vs5Wi7ArufHzC14AC3JlEbM3HQ6x4LvAc Uyz63G7nWgrU4JiJKOiUjoX16DUqE99ACCHth+Rv7YtmqCLhn7i4e75/Iy7iK6e+GRK/ Ah4uiiMW1WUDMYzSWAzULNFeXmDwFZBQr+vuhhqDXtXGf109qt6cCORsvI17Q8nrvqlN +f6w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a056402524700b00461c5846e1asi7504720edd.371.2022.12.02.05.57.02; Fri, 02 Dec 2022 05:57:24 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233552AbiLBNfC (ORCPT + 83 others); Fri, 2 Dec 2022 08:35:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233676AbiLBNe4 (ORCPT ); Fri, 2 Dec 2022 08:34:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CDDEC3598; Fri, 2 Dec 2022 05:34:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0C4E6B82158; Fri, 2 Dec 2022 13:34:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B85AAC433C1; Fri, 2 Dec 2022 13:34:49 +0000 (UTC) Date: Fri, 2 Dec 2022 08:34:48 -0500 From: Steven Rostedt To: Dan Williams Cc: , Alison Schofield , Vishal Verma , "Ben Widawsky" , Jonathan Cameron , Davidlohr Bueso , Dave Jiang , , Subject: Re: [PATCH V2 03/11] cxl/mem: Implement Clear Event Records command Message-ID: <20221202083448.4b3b3254@gandalf.local.home> In-Reply-To: <6389630036769_3cbe02947d@dwillia2-xfh.jf.intel.com.notmuch> References: <20221201002719.2596558-1-ira.weiny@intel.com> <20221201002719.2596558-4-ira.weiny@intel.com> <6389630036769_3cbe02947d@dwillia2-xfh.jf.intel.com.notmuch> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 On Thu, 1 Dec 2022 18:29:20 -0800 Dan Williams wrote: > > static void cxl_mem_get_records_log(struct cxl_dev_state *cxlds, > > enum cxl_event_log_type type) > > { > > @@ -732,13 +769,22 @@ static void cxl_mem_get_records_log(struct cxl_dev_state *cxlds, > > } > > > > nr_rec = le16_to_cpu(payload->record_count); > > - if (trace_cxl_generic_event_enabled()) { > > + if (nr_rec > 0) { > > int i; > > > > - for (i = 0; i < nr_rec; i++) > > - trace_cxl_generic_event(dev_name(cxlds->dev), > > - type, > > - &payload->records[i]); > > + if (trace_cxl_generic_event_enabled()) { > > Again, trace_cxl_generic_event_enabled() injects some awkward > formatting here to micro-optimize looping. Any performance benefit this > code might offer is likely offset by the extra human effort to read it. This is commonly used throughout the kernel, and highly suggested for use to encapsulate any work being done only for tracing, when tracing is disabled. It uses static_braches/jump_labels which makes the loop into a 'nop' when tracing is off. That is, there is zero overhead for the for loop below (and there's not even a branch to skip it!) But sure, if you really don't care as it's not a fast path, then keep it out. I like people to keep the habit of doing this, because otherwise it tends to creep into the fast paths. -- Steve > > > + for (i = 0; i < nr_rec; i++) > > + trace_cxl_generic_event(dev_name(cxlds->dev), > > + type, > > + &payload->records[i]); > > + } > > + > > + rc = cxl_clear_event_record(cxlds, type, payload, nr_rec); > > + if (rc) { > > + dev_err(cxlds->dev, "Event log '%s': Failed to clear events : %d", > > + cxl_event_log_type_str(type), rc); > > + return; > > + } > > } > >