Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp402973ybl; Mon, 2 Dec 2019 12:29:59 -0800 (PST) X-Google-Smtp-Source: APXvYqyqlkaj7jC1sR3UeMW9wFIphIbU/kyPHcC0T8Y6Zxh/3fcrKniC1wdsbSBEGbvlAZ3FySYQ X-Received: by 2002:aca:72cd:: with SMTP id p196mr692053oic.99.1575318599124; Mon, 02 Dec 2019 12:29:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575318599; cv=none; d=google.com; s=arc-20160816; b=J0K3EMCPic3nYN4Ggz3jbvwzP8DwygBKDzn0G+U4UYnAsZLUZePDSoVPvTeT5sEybr 6gd3otB7QOPoQg7ykbGLkuHMioH7Nln5UTQRKtG1aSWJWtaqjNE3kZwBGVvmGGyMkSSu C4urkRVgtjCJ0r/i1s/lfQ511X2TcqAt/96aajvZFn/ztl5Dm7QI89qYMYrO7MDnfggw c3ZY8LRIkMA57bA6lBeokkNHznGNhtwz2xz6q2gqHWA9WAwUgj3gEuk7cNVbkklPDY0R oFsgme3iDoobUIXhvx1stW+Tu9mDuO14pl9PvEVbj+0jP02wU6wkyEi4M19TDBgJNPyK cA1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ioFZQLl7w/1rVGBT9tbKXUrON6Sf9uqURta2HTAzk7c=; b=u85Xp6mKKrGL+kvdYgii7YWTFS6SBCs7OTxu0xu1DqGsL5cHgKMBgX3IETwrc692f6 MxCynT2AMymLZs6zM9NAWA5Bz/XoNRilATl6rTFJ+ZKPG667TIvqZnLNA4cu2htMWCer ce8kOaEezZuBmYM0M23KLbx08RF/IgAEfcVoztALQ7yXlAUzrPHRgKMHW25woqZZG44Q qdP8f4WJt7znCtdYm0kTPAhrsizd+7/kbCy5UcntxU+diKSACrRpPH1lJiF2Dk9jMlsD ICaPJCNVcLMBS+/rjRMp48r1wHQ9ig7HkBML8LfKhtKWtkbgYL3B4nu0OmO0V9oHNwsF g8RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si103493otr.102.2019.12.02.12.29.46; Mon, 02 Dec 2019 12:29:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727634AbfLBUZg (ORCPT + 99 others); Mon, 2 Dec 2019 15:25:36 -0500 Received: from mga17.intel.com ([192.55.52.151]:38875 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727420AbfLBUZg (ORCPT ); Mon, 2 Dec 2019 15:25:36 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Dec 2019 12:25:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,270,1571727600"; d="scan'208";a="385024237" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.21]) by orsmga005.jf.intel.com with ESMTP; 02 Dec 2019 12:25:35 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id 97D85300B57; Mon, 2 Dec 2019 12:25:35 -0800 (PST) Date: Mon, 2 Dec 2019 12:25:35 -0800 From: Andi Kleen To: "Liang, Kan" Cc: Peter Zijlstra , mingo@redhat.com, acme@kernel.org, tglx@linutronix.de, bp@alien8.de, linux-kernel@vger.kernel.org, eranian@google.com, alexey.budankov@linux.intel.com, vitaly.slobodskoy@intel.com Subject: Re: [RFC PATCH 3/8] perf: Init/fini PMU specific data Message-ID: <20191202202535.GO84886@tassilo.jf.intel.com> References: <1574954071-6321-1-git-send-email-kan.liang@linux.intel.com> <1574954071-6321-3-git-send-email-kan.liang@linux.intel.com> <20191202124055.GC2827@hirez.programming.kicks-ass.net> <20191202145957.GM84886@tassilo.jf.intel.com> <20191202162152.GG2827@hirez.programming.kicks-ass.net> <20191202191519.GN84886@tassilo.jf.intel.com> <8612523d-f035-b2aa-28f5-e4122ef59901@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8612523d-f035-b2aa-28f5-e4122ef59901@linux.intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Looks reasonable to me. > //get current number of threads > read_lock(&tasklist_lock); > for_each_process_thread(g, p) > num_thread++; > read_unlock(&tasklist_lock); I'm sure we have that count somewhere. > > //allocate the space for them > for (i = 0; i < num_thread; i++) > data[i] = kzalloc(ctx_size, flags); > i = 0; > > /* > * Assign the space to tasks > * There may be some new threads created when we allocate space. > * new_task will track its number. > */ > raw_spin_lock_irqsave(&task_data_events_lock, flags); > > if (atomic_inc_return(&nr_task_data_events) > 1) > goto unlock; > > for_each_process_thread(g, p) { > if (i < num_thread) > p->perf_ctx_data = data[i++]; > else > new_task++; > } > raw_spin_unlock_irqrestore(&task_data_events_lock, flags); Is that lock taken in the context switch? If not could be a normal spinlock, thus be more RT friendly. -Andi