Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp648063imm; Wed, 4 Jul 2018 03:37:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfsOfZH8HOu/fnR7dXVu3zJlAbsYtrPjxF62SHRI6ag1k+TkeVm8RMnD/VFCoz+ElmpK8HG X-Received: by 2002:a65:4c41:: with SMTP id l1-v6mr1440234pgr.310.1530700653444; Wed, 04 Jul 2018 03:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530700653; cv=none; d=google.com; s=arc-20160816; b=FwPOMZYfXQPTLuWQV1lJkN57RjZMJ9xtnq61WDNktkz7ZiDpw3XgOZ3w8spK+N5LF/ FEjPEsTXSoWK3Vpal1D8KfAEz0v88obcexR21wGgc/HUCHQWbkUqfopKxSUKiIUD3Ux4 KharSaiwAc1yUxVEZc2LWzjpYGX+mewChs1+V3GplafSH4zjBmo8GPO7kBLH8nfa3RgM fZK/X4a+OL0YECQi47UazntrEzON+bqSUtVcVEJVww4B1rVEpXS2u+X6iRJRiMM/4iD6 DoCEii5aGUvZxMjGBmoPRCafKPRH7NWEbWNREKqv7j9L9OJ0pY/uFeJMIE2aEcuw9Xw8 21/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from :arc-authentication-results; bh=UlnFgJaBV/tTe8vuITnlxnnLMpxeNGfNuc/AkIUq6t8=; b=jqtP8NdoEUMMtSBf1Noz05cywedzUIFVz6DY0WqlJ1OAAe//bEpkZTpIXZsv8WzLmM zfhcPbFHeGN46Mm9/3SCGIW4u0brD6iiDdVl4FpgPmf+cLGt7rhvo/cClBetXOTgFgeb 08qV029bMd49JXhQocEyP80uwDTv9/q1f5+TXTcA5vMj7WMbhe9+3VxQro8H7q8J4RzB VeAOssErp3TPbxnLNn+J2GvXqVlQ4Id2Joroowt6HiWCDGKH//RHUvalY6mxedgNrfU9 AKBlqPlPgJdKDjJWzVO3Qvv3f+ZhM065+1ou2NPpKMTG1A93kiXMEfvgI6m0Y05qwmYn Z/BA== 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 g3-v6si3164748pld.309.2018.07.04.03.37.14; Wed, 04 Jul 2018 03:37:33 -0700 (PDT) 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 S933525AbeGDKfw (ORCPT + 99 others); Wed, 4 Jul 2018 06:35:52 -0400 Received: from mga11.intel.com ([192.55.52.93]:54342 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753048AbeGDKfu (ORCPT ); Wed, 4 Jul 2018 06:35:50 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 03:35:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="62208992" Received: from um.fi.intel.com (HELO um) ([10.237.72.212]) by FMSMGA003.fm.intel.com with ESMTP; 04 Jul 2018 03:35:45 -0700 From: Alexander Shishkin To: Mathieu Poirier Cc: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , Thomas Gleixner , Alexander Shishkin , schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, Will Deacon , Mark Rutland , Jiri Olsa , Namhyung Kim , Adrian Hunter , ast@kernel.org, Greg KH , "H. Peter Anvin" , linux-s390@vger.kernel.org, Linux Kernel Mailing List , linux-arm-kernel Subject: Re: [PATCH 5/6] perf/core: Use ioctl to communicate driver configuration to kernel In-Reply-To: References: <1530570810-28929-1-git-send-email-mathieu.poirier@linaro.org> <1530570810-28929-6-git-send-email-mathieu.poirier@linaro.org> <20180703100348.fy43f4fosw3fdc6i@um.fi.intel.com> <20180703105652.psjq5cq4t7o2j6zk@um.fi.intel.com> User-Agent: Notmuch/0.27 (http://notmuchmail.org) Emacs/25.2.2 (x86_64-pc-linux-gnu) Date: Wed, 04 Jul 2018 13:34:41 +0300 Message-ID: <87fu0z70hq.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mathieu Poirier writes: > On Tue, 3 Jul 2018 at 04:57, Alexander Shishkin > wrote: >> >> On Tue, Jul 03, 2018 at 01:03:48PM +0300, Alexander Shishkin wrote: >> > On Mon, Jul 02, 2018 at 04:33:29PM -0600, Mathieu Poirier wrote: >> > > +/* >> > > + * PMU driver configuration works the same way as filter management above, >> > > + * but without the need to deal with memory mapping. Driver configuration >> > > + * arrives through the SET_DRV_CONFIG ioctl() where it is validated and applied >> > > + * to the event. When the PMU is ready it calls perf_event_drv_config_sync() to >> > > + * bring the configuration information within reach of the PMU. >> > >> > Wait a second. The reason why we dance around with the generations of filters >> > is the locking order of ctx::mutex vs mmap_sem. In an mmap path, where we're >> > notified about mapping changes, we're called under the latter, and we'd need >> > to grab the former to update the event configuration. In your case, the >> > update comes in via perf_ioctl(), where we're already holding the ctx::mutex, >> > so you can just kick the PMU right there, via an event_function_call() or >> > perf_event_stop(restart=1). In the latter case, your pmu::start() would just >> > grab the new configuration. Should also be about 90% less code. :) >> >> Also, since it affects the AUX buffer configuration, it is probably a one >> time ioctl command that you issue before you mmap the buffer. If that's >> the case, you don't even have to worry about stopping the event, as it >> shouldn't be running, because without the buffer perf_aux_output_begin() >> should fail and so should the pmu::add() iirc. >> > > The idea behind the current approach was to make the SET_DRV_CONFIG > ioctl() usable by other drivers where multiple ioctl() calls could be > performed while a session in ongoing. I also opted to introduce a > _sync() function to let the PMU refresh its configuration at the time > of its own choosing rather than having to interrupt the session. Yes, but the times of PMU's own choosing would still be more or less limited to ->start()/->stop(). You can also do an event_function_call(), which would call ->config_sync(), which would be free to decide what to do with the new information, up to and including doing a ->stop()/->start() sequence. My guess is that you'd want to do either of the following: * decide to apply the new configuration immediately, and do the start-stop thing, * decide to defer the new configuration until the next ->start(). Both should work via cross call directly from the ioctl() call. > But all I need for coresight is to have available the sink information > and PMU configuration (in an upcoming patchset) by the time > setup_aux() is called. You are correct, this is a one time > configuration and since the event isn't running there is no need for > locking - I should be able to access the PMU when the ioctl is called. > > If you are fine with this bare-bone scenario and don't care much about > usability in different situation, I'll do a respin with minimal > functionality that cover my needs. It doesn't have to be bare-bones, what I'm saying is that you shouldn't need the event->drv_config, as you can directly call pmu::config(new_config) (or config_sync(), but I'm guessing the _sync part is redundant if you don't keep the configuration in 2 parts) from the ioctl() and it should cover all your bases. Regards, -- Alex