Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp217254ybl; Mon, 2 Dec 2019 09:44:09 -0800 (PST) X-Google-Smtp-Source: APXvYqx4ZhepOZOwHbOFigo9CMuGZ+hZhTi8RYhT1LpPJSkP6X8mrzqh2zetVJ8au4lcxGb5IE5U X-Received: by 2002:aa7:c742:: with SMTP id c2mr6614308eds.261.1575308649463; Mon, 02 Dec 2019 09:44:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575308649; cv=none; d=google.com; s=arc-20160816; b=HajQ0jrXY21TWOVE6upxN26dMaY3SE95g7qc7TU9mAvNzK1z/Xz4PWb0aEWuwcl6aJ EdtHgfMiXhPBuKPMGBuSNXdXNmadb/xq7WlOqrYvWRz77L1IajIFSMZdutG9zBngjGz4 IsQpcDWzNGq+ktT/FaFFcchZXtAoLFMZCe7CWRHo9rQxKpwmkvvxr+vDeTqvZonVnSYF MGCTgMOeZBzdKVCNsY3f1v4xDNw0461uudgMheIbyvN7wJs3a/avGQn4CKjH/RWr6iiP ikkwxSVfRmxhe93wNsndQ5WuUMxMtd8fCoiuPInp+016SD9sk+FSmScfHekoGQhy72Nk yQSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=TlET7/qZ31JCP3ABYyOCu6AwI9DFwtYHZggxO9cnHdc=; b=h8beVr7FSfj1qopaafLeUYFkh8T6Be8eYRJGn42w2wYMmzswAw/HK6NIvoHeTRtNRX 7daE8q1aY97BAIRiPsSBZWBJ2GntztdMUbNWimRzEugWycY8g/+7rk9TUbcN7y4YPMvr ezYxyeScSCEBH4l+xFkI2TiaRZKxgGxAl96cbjbWMkaWsh4NKrgw1d05IhzkOuQfsdLv r9VFGvOY5qEmzTAM+6uS+Dm5HiJ97gMK3jrS83jCXEUKKteNfpAbYz1pqgT0YN5b2rMk X6rPM7L5Qc2+Ybw+Wq30l560pF6Qzgl61JxtYjeeLc3dIZqOloD9BSaRieCWMemWKWNP qseQ== 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 n18si19801edr.388.2019.12.02.09.43.45; Mon, 02 Dec 2019 09:44:09 -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 S1727750AbfLBRmY (ORCPT + 99 others); Mon, 2 Dec 2019 12:42:24 -0500 Received: from mga18.intel.com ([134.134.136.126]:65448 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbfLBRmY (ORCPT ); Mon, 2 Dec 2019 12:42:24 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Dec 2019 09:42:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,270,1571727600"; d="scan'208";a="262288999" Received: from linux.intel.com ([10.54.29.200]) by FMSMGA003.fm.intel.com with ESMTP; 02 Dec 2019 09:42:22 -0800 Received: from [10.125.253.1] (abudanko-mobl.ccr.corp.intel.com [10.125.253.1]) by linux.intel.com (Postfix) with ESMTP id 257075800FF; Mon, 2 Dec 2019 09:42:19 -0800 (PST) Subject: Re: [RFC PATCH 3/8] perf: Init/fini PMU specific data To: Peter Zijlstra , Andi Kleen Cc: kan.liang@linux.intel.com, mingo@redhat.com, acme@kernel.org, tglx@linutronix.de, bp@alien8.de, linux-kernel@vger.kernel.org, eranian@google.com, vitaly.slobodskoy@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> <79138ea7-2249-b7e0-3541-8569e593c6e8@linux.intel.com> <20191202164313.GM2844@hirez.programming.kicks-ass.net> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Mon, 2 Dec 2019 20:42:18 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191202164313.GM2844@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02.12.2019 19:43, Peter Zijlstra wrote: > On Mon, Dec 02, 2019 at 07:38:00PM +0300, Alexey Budankov wrote: >> >> On 02.12.2019 17:59, Andi Kleen wrote: >>>> >>>> This is atricous crap. Also it is completely broken for -RT. >>> >>> Well can you please suggest how you would implement it instead? >> >> FWIW, >> An alternative could probably be to make task_ctx_data allocations >> on the nearest context switch in, and obvious drawback is slowdown on >> this critical path, but it could be amortized by static branches. > > Context switch is under a raw_spinlock_t too. Indeed, under rq->lock (some of runqueue locks, I suppose), but as far locking order is not violated a thread shouldn't deadlock. On the other side it could probably hurt concurrency and it is more preferable to have task_ctx_data memory pre-allocated by the time it is assigned on a context switch in. What if we would create some pool of preallocated task_ctx_data objects on the first system wide perf_event_open() syscall and after that: - already existing threads would take task_ctx_data objects from the pool without additional locking on the nearest context switch in; - newly created threads would allocate task_ctx_data themselves, atomically checking some global state, possibly at PMU object - task_ctx_data deallocation would be performed by threads themselves, at some safe points in time; Thanks, Alexey