Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1520354ybl; Mon, 2 Dec 2019 04:45:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwzYlNpAix1Y3w3sMDhJHP0aVt4jIbLTdPqJz/Q4772bR5gatuj1JqVQN8/RNGJ0o/f6Hdp X-Received: by 2002:a17:906:b253:: with SMTP id ce19mr52192119ejb.61.1575290705588; Mon, 02 Dec 2019 04:45:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575290705; cv=none; d=google.com; s=arc-20160816; b=GPlMGHlc8OGz0IjbhRcD69Fag8xLaOQCyvdLu3gUGCtOZbakPCXJX6XfQZpV4evtC4 CTfUB/ZLHYfyM8+u9yVN4rh2qU/wXuqxX2J/uBESjDyvRm5BEVcREOjStGj6dtlhxqTO r4z6togW2/pS4z+yJNXcGDJ7hVVnNIeHdZ30BUfC31/Rdval1G8oZR23idgn8rjvQ9N7 bD2pIk9i/qbkhSbRca0lpxdvRsrH97UdQp9uiJaH7WQhdryVKOQrtgdGFSK9nZ8XIcig UZBq6Y6v3XNMyU4dRKfPiObdO7tUM7UuMsTJX6zt1UJrRXp6zafR3kAG585QYoqRtaBO neOA== 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:dkim-signature; bh=QQVFiLaKtWz8/87xlWuZWGTM6aKj6MiwHzOhtOqM+Kg=; b=D1qr56SdaSmuC/jdw/J7sdMZiLbNQj0ZqMBLP9AztMeiYUO9LyUejZViDnlvhz4C+s GRtnrW6oDHmxpw84ewyhU5u4YW8aIsCWKAgw8IDHq6Klc7qzDBYrey1rU4msy2GhjPks TGgra3T9oGo2yZUVUGQnUNLtkl+obdeAkmvopdAon9vq2LJxbPjSqT43c1i3BjvjffL2 PhpH5eYVy/eT0HYkv9uHFiQjIKt8XszOk3M1uxkhKSFRbwYN/xBG11T3oDXHqwKEEutd Wkdu4i0NUKrdD5TL34+VK4E0n6bbpTMaoJzv0bl9YZ0esxlrHjAk59iA4/yxPekkS58J cr3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=RgVYKa+F; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si27333800edj.194.2019.12.02.04.44.36; Mon, 02 Dec 2019 04:45:05 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=RgVYKa+F; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727445AbfLBMlL (ORCPT + 99 others); Mon, 2 Dec 2019 07:41:11 -0500 Received: from merlin.infradead.org ([205.233.59.134]:44038 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727354AbfLBMlL (ORCPT ); Mon, 2 Dec 2019 07:41:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QQVFiLaKtWz8/87xlWuZWGTM6aKj6MiwHzOhtOqM+Kg=; b=RgVYKa+Fv+UL9Bo3kZWCRmezD v6ob10/58yNO8kTMUqM+WP7DSOCvOqBZQsLxiWqpzNzBHMzN0lhCupEACXAQQ2CXo+SXxWkt+Ow11 1MIotONSRD5h97ojPAijNKyfySu6Nm4BGwZgtnkmsMQ0kY+Rp8QDe6Un1R5mzdX2HRsAczi/2p/0J LCT5q2EmdKnifoFUqmzOi7LZ/MLJE8j2qgwEJGpijXMWZygM4+eYKDPm9DJjbbZUTtdquTZNpj5RE Vk9FSkCsyGnaANQ9s26JL2gLat4hMBavpRLUr1OEwEoT7AbtENC3NWy3aba0glXt3AMzkLVQPgrlx 6sS40t0AQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ibl0c-0007qf-38; Mon, 02 Dec 2019 12:40:58 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8EEA3301A6C; Mon, 2 Dec 2019 13:39:39 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6AEB220236A49; Mon, 2 Dec 2019 13:40:55 +0100 (CET) Date: Mon, 2 Dec 2019 13:40:55 +0100 From: Peter Zijlstra To: kan.liang@linux.intel.com Cc: 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, ak@linux.intel.com Subject: Re: [RFC PATCH 3/8] perf: Init/fini PMU specific data Message-ID: <20191202124055.GC2827@hirez.programming.kicks-ass.net> References: <1574954071-6321-1-git-send-email-kan.liang@linux.intel.com> <1574954071-6321-3-git-send-email-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1574954071-6321-3-git-send-email-kan.liang@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 28, 2019 at 07:14:26AM -0800, kan.liang@linux.intel.com wrote: > +static int > +init_system_wide_ctx_data(size_t ctx_size) > +{ > + struct task_struct *g, *p; > + int failed_alloc = 0; > + unsigned long flags; > + > + /* > + * Allocate perf_ctx_data for all existing threads by the first event. > + * > + * The perf_ctx_data for new thread will be allocated in > + * perf_event_fork(). The perf_event_fork() is called after the thread > + * is added into the tasklist. It guarantees that any new threads will > + * not be missed. > + */ > + raw_spin_lock_irqsave(&task_data_events_lock, flags); > + if (atomic_inc_return(&nr_task_data_events) > 1) > + goto unlock; > + > + read_lock(&tasklist_lock); > + > + for_each_process_thread(g, p) { > + /* > + * The PMU specific data may already be allocated by > + * per-process event. Need to update refcounter. > + * init_task_ctx_data_rcu() is called here. > + * Do a quick allocation in first round with GFP_ATOMIC. > + */ > + if (init_task_ctx_data_rcu(p, ctx_size, GFP_ATOMIC)) > + failed_alloc++; > + } This is atricous crap. Also it is completely broken for -RT.