Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp566745ybt; Wed, 24 Jun 2020 06:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPHOqq2K7lor0obefoQtb8wD/L1k9L0muZeGagpsP7eSA3E+FfuevQjJlTdxmq0u+nUA3/ X-Received: by 2002:a17:906:ca0e:: with SMTP id jt14mr24339013ejb.325.1593004197305; Wed, 24 Jun 2020 06:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593004197; cv=none; d=google.com; s=arc-20160816; b=lclz24Fh+e/4vtempAFSgqhc1cS42mjg465XIdnOPzA2ylSYyj4GDnv5PXaCaze0fb bFUedhFIoYjpZ+Pp9K9fa0/wUdDJMC//J765Scp0VASJgEjtYL474HyBEH+PgghyrcUG C6HCX+AQz7+VOLQZpP1gBR26XhmK2yyD3ngxIkgOzMcApX42cT00vL3IwYKwRFNFavl7 KVrtl4x7FOvTSBTmTEO0N8ylcdM5ejJfTVQuSQd2D9gZ7bBKn9wKKGVoFCFw5Rt+zYrv mia9RKgLX/Di/B0D2oKJ1jHJaCBpJkeWvx/wy9dflqAd3g1cqDb0ayUAw+a0SH6dQSuM sO5g== 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:from:references:cc:to:subject; bh=I8E90FW7fvKRa7kFcL3rm01ETBwjuN/t9smkgqVIEI8=; b=nYaIN7uknx4azgCYdACMzDJ4eZm/vqT7ZemJtGiYTL6aVQJ43xDqml6jJeCqCx/eUu T7W8/xqtZNa+NjDTzt6/QU8AXMHlBl9rU5pclXRpt2KR9a5BKTX282XEh/OfI5eCEp9+ 7w+BUvAqygh9p/UaLAg6zLWODkzJMljLIzb4ZiwdM31oP9GJatHb+hj3qZ04PJNw1BSF KW/t5tNxsa2FMEIWplo57QMSLmExxaw8E4AuAMAOxrv/Bim3DrGzhwpsCkfq0pOOzEkE A7K70HrhVz8maFREiU3dDGo6xP3/q9KP8fPiZkWhDdQ4+mMKKc68+C/nNPc7FVuktlBb oagg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si14041277edl.102.2020.06.24.06.09.33; Wed, 24 Jun 2020 06:09:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389328AbgFXNIe (ORCPT + 99 others); Wed, 24 Jun 2020 09:08:34 -0400 Received: from foss.arm.com ([217.140.110.172]:47520 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728843AbgFXNIe (ORCPT ); Wed, 24 Jun 2020 09:08:34 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3C4F51F1; Wed, 24 Jun 2020 06:08:33 -0700 (PDT) Received: from [10.57.9.128] (unknown [10.57.9.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E89FE3F6CF; Wed, 24 Jun 2020 06:08:31 -0700 (PDT) Subject: Re: [RFC PATCH] perf/smmuv3: Fix shared interrupt handling To: Will Deacon Cc: mark.rutland@arm.com, tuanphan@os.amperecomputing.com, john.garry@huawei.com, linux-kernel@vger.kernel.org, shameerali.kolothum.thodi@huawei.com, harb@amperecomputing.com, linux-arm-kernel@lists.infradead.org References: <20200624125045.GC6270@willie-the-truck> From: Robin Murphy Message-ID: Date: Wed, 24 Jun 2020 14:08:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200624125045.GC6270@willie-the-truck> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-24 13:50, Will Deacon wrote: > On Wed, Jun 24, 2020 at 12:48:14PM +0100, Robin Murphy wrote: >> On 2020-04-08 17:49, Robin Murphy wrote: >>> IRQF_SHARED is dangerous, since it allows other agents to retarget the >>> IRQ's affinity without migrating PMU contexts to match, breaking the way >>> in which perf manages mutual exclusion for accessing events. Although >>> this means it's not realistically possible to support PMU IRQs being >>> shared with other drivers, we *can* handle sharing between multiple PMU >>> instances with some explicit affinity bookkeeping and manual interrupt >>> multiplexing. >>> >>> RCU helps us handle interrupts efficiently without having to worry about >>> fine-grained locking for relatively-theoretical race conditions with the >>> probe/remove/CPU hotplug slow paths. The resulting machinery ends up >>> looking largely generic, so it should be feasible to factor out with a >>> "system PMU" base class for similar multi-instance drivers. >>> >>> Signed-off-by: Robin Murphy >>> --- >>> >>> RFC because I don't have the means to test it, and if the general >>> approach passes muster then I'd want to tackle the aforementioned >>> factoring-out before merging anything anyway. >> >> Any comments on whether it's worth pursuing this? > > Sorry, I don't really get the problem that it's solving. Is there a crash > log somewhere I can look at? If all the users of the IRQ are managed by > this driver, why is IRQF_SHARED dangerous? Because as-is, multiple PMU instances may make different choices about which CPU they associate with, change the shared IRQ affinity behind each others' backs, and break the "IRQ handler runs on event->cpu" assumption that perf core relies on for correctness. I'm not sure how likely it would be to actually crash rather than just lead to subtle nastiness, but wither way it's not good, and since people seem to be tempted to wire up system PMU instances this way we could do with a general approach for dealing with it. Robin.