Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp117823imm; Tue, 3 Jul 2018 15:10:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc091E1EPiUJo0jEV2mUQZdjExcK6SmfdJZuTblcpg3TjV1MeoLCQIXvjAuLydJRygCOiw5 X-Received: by 2002:a63:e0b:: with SMTP id d11-v6mr103771pgl.134.1530655810171; Tue, 03 Jul 2018 15:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530655810; cv=none; d=google.com; s=arc-20160816; b=jaAsSKdWQz12lbq6lLw4rvuNxjSzdfAkfwBsQTwzk44yH6CDn4idE91Gn5lZJVTWax d/NpogOtuHsuaFe6qTgtfrdf+rHNfa4QX2EZwv2hDRsGuKQuNHQ52ZwLUKHKbeHVuRgz ojfL57NPypAR33qSoeBjvPFxVF7Rby1TgvvljZZIhGn0FjtvwmM6BVJSO0YqFvBi3nrN gKHQNx6ACOnq0z988vDzuBVzd5/8YymkTA+w0xkj9qodDLQHxfpfwvgkqJuvyO7RJcR3 Qr1t9W12Wn6Role6MQYMJzWmThQdvivDJ+4SbR8BBHjdj+Oeyu0Jac+2ZF6CoIuVWoAf JhPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=1NDtu3iLaFTbyqoVjiuXvC55TtLfjP7L5m+Gsq4zK1Q=; b=KHtRgs3yjyNhVGKBF/AaXse4C9E4U/ITzFBIY7a90CeMJPbKiwrcfaW/xLgl6EGrun 62zTv86ci2irBW/rFJKZLA75jB26IJ2E+rhx181iaevcY0OS5wrJIBrSnafJl4cl9H1Q wRQ4U6bUr8TRLDgvvJ9AVHkPua5MV+ZXdwp6JqUBp2F/O7WnaEmkIBUu+eKYoxrAMA3H Z8viXEqHPRhSXZkEOwZkbJa5aKeElqABRfhZSKm/0zvsYVGA+UQOnAf2VBMgU7wnJs6N g8CepJzVcyCsjFM8id7R4HVoc3ogiurMj8tE3vdi5v52cPcDkcM6XKeMwxc19jLdX749 RLNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hfpc5PZs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10-v6si1765904pgq.187.2018.07.03.15.09.55; Tue, 03 Jul 2018 15:10:10 -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; dkim=pass header.i=@linaro.org header.s=google header.b=hfpc5PZs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753439AbeGCWHY (ORCPT + 99 others); Tue, 3 Jul 2018 18:07:24 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:41991 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932434AbeGCWAv (ORCPT ); Tue, 3 Jul 2018 18:00:51 -0400 Received: by mail-ed1-f68.google.com with SMTP id g12-v6so2616874edi.9 for ; Tue, 03 Jul 2018 15:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=1NDtu3iLaFTbyqoVjiuXvC55TtLfjP7L5m+Gsq4zK1Q=; b=hfpc5PZsj1EOVsKOM8EbWqpo83ot/2EYsuB8iNjsz8QcVPQtadLTAlA7qEIVY0lRUe WdkZxo5lartJfFD8m2J9KhYHmqgwy+iofV8BjB59fKPSUQuP7oMUDkaXXepSUFVGq48s pk2LFKSTAEDrhQu85Z5HugYqtt8upxBQB/bb0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=1NDtu3iLaFTbyqoVjiuXvC55TtLfjP7L5m+Gsq4zK1Q=; b=iii/Jt2BtVyRBYyp8hgndXpMT0StiHaTrdA7+KCaSomS65CWH6rFiboureImLI3m8Q 5IqmcNfxCrn4l+lrf0XtsYqFUklTDDXysMmCt5PE31NSJehk1+GHeGIPcKvF6H5NZjv7 sYKl8EyI9ha3Tk4/TmOOwF7ZaDbHM2x0SLf1kMUlBVxW9yTwf+QbHMIfVbJV1N635deO V6cA9o4FSpos+LaRg60fmzFnE/+0iaT1L9TwOj3zYPP1nDBEHnV4nufeQqh5rQ2P2+hj 9Jqi7m5cOGktfc/dKd9Y6iVImmQRDvRTMmg+EVdxOXzj4zhq8aE+iAoKaM6OxkDvtkhk qjmQ== X-Gm-Message-State: APt69E32v2OpBJTwIk2aDqbkZ4I7ilqfmkTjzIT8GQwTX4SgujNdZzkd rB1fo+FbzUODO4srLD8/0uybo98JLCngp4K6NLJkMA== X-Received: by 2002:a50:8fe4:: with SMTP id y91-v6mr29939317edy.295.1530655250672; Tue, 03 Jul 2018 15:00:50 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <20180703105652.psjq5cq4t7o2j6zk@um.fi.intel.com> From: Mathieu Poirier Date: Tue, 3 Jul 2018 16:00:39 -0600 Message-ID: Subject: Re: [PATCH 5/6] perf/core: Use ioctl to communicate driver configuration to kernel To: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. Thanks for the review, Mathieu > Regards, > -- > Alex