Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1691696pxj; Fri, 18 Jun 2021 12:48:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhkqzfVJ/tUXj56H7LWZou1t3zaCX0MWA9SkuRLwQ46ayhO6pklFlOYsd9+VHWN8D1PF2O X-Received: by 2002:a17:907:2648:: with SMTP id ar8mr12487811ejc.521.1624045691625; Fri, 18 Jun 2021 12:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045691; cv=none; d=google.com; s=arc-20160816; b=z9/Iu2kHLMhgg0EpX+3k4997l0oZgisUtMgOeqEySrDpfxP6uDHR1NqKvKYaZanPNz Ka2xVmMtuFzHCkUmJR7exS3cz6J8zBAjb7SEa2Xu13u6It6DkwhZJJFDlkdle3/DZP3B KEeCZZrKu1+WaTEWnKTRBQHoE6ScwL0VkBUf7gxzTQUmAC5bf3Qg3Lg53aXat5TFinJ9 rsTSZHm8HRd6pjKktzw1oKHsoFJ+QcU0OJEQ1pXeNxSklxc6FcF9PgZy4JMgeD7FNbLy DU73O9fbxtnNbsWJ8Gd8cgOjVvOhHHjNwCJZ/DYd7N+uod+XD7dKdgSue0BbL9tiLzvF y1Cg== 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=GhxSMC5iKsBaUlvoN63/E/o7NoWNP2dizwoiPebs9dU=; b=ZhekhXMJffCCWkqiJAxwmSg8AdVqoS4iTBI2siRw+tQfPgcwiK7Ln5uR/M0z4Xl/yu OwgX2V2nGvTH0pbqcafE1COcnOfzWyJvdPY4cVfH3QWMdMGxvDyh5VI76wXMApuhVPb4 XiclWiHm3Jwnbfiv4yaPgZcT2A5qdG8rURqkDwMEF/aH64WzjQV5zvd3huDnv4NNTmBB ex0ygM5thtD6ADUAzL+feY9ifQquI6158JMrM8eyJiS6W6jxCDHGfs/u6u9wR8LqOzLo NvnWDefPxV2ufcnvodidOueb5Lm91m5MXu2DNN2BIyIBhV5rChSV69+xFrAzHCF529/F 4f7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi20si10434693edb.462.2021.06.18.12.47.49; Fri, 18 Jun 2021 12:48:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234535AbhFRTCe (ORCPT + 99 others); Fri, 18 Jun 2021 15:02:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:58032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231589AbhFRTCd (ORCPT ); Fri, 18 Jun 2021 15:02:33 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 39E25610EA; Fri, 18 Jun 2021 19:00:22 +0000 (UTC) Date: Fri, 18 Jun 2021 15:00:20 -0400 From: Steven Rostedt To: Daniel Bristot de Oliveira Cc: Phil Auld , Sebastian Andrzej Siewior , Kate Carcia , Jonathan Corbet , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexandre Chartre , Clark Willaims , John Kacur , Juri Lelli , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V4 05/12] trace/hwlat: Support hotplug operations Message-ID: <20210618150020.689439d4@oasis.local.home> In-Reply-To: <20210618124503.388fe4d4@oasis.local.home> References: <8899f8a8bec38bc600f7a2c61bc6ca664aa7beeb.1623746916.git.bristot@redhat.com> <20210618124503.388fe4d4@oasis.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 18 Jun 2021 12:45:03 -0400 Steven Rostedt wrote: > > +/* > > + * hwlat_cpu_init - CPU hotplug online callback function > > + */ > > +static int hwlat_cpu_init(unsigned int cpu) > > +{ > > + struct trace_array *tr = hwlat_trace; > > + > > You need to take the trace_types_lock here, between testing the > hwlat_busy and starting the threads. Otherwise, between the two, the > hwlat tracer could be turned off while a CPU is coming on line, and > then you just started a per cpu thread, while the hwlat tracer is not > enabled. And of course, because get_online_cpus() is called within trace_types_lock, doing this check is going to cause a lock inversion. The only thing I could think of is to wake up a worker thread to do the work. That is, this just wakes the worker thread, then the worker grabs the trace_types_lock, iterates through the cpu mask of expect running threads, and then starts or kills them depending on the hwlat_busy value. -- Steve > > > + if (!hwlat_busy) > > + return 0; > > + > > + if (!cpumask_test_cpu(cpu, tr->tracing_cpumask)) > > + return 0; > > + > > + return start_cpu_kthread(cpu); > > +}