Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2076956ybh; Fri, 24 Jul 2020 03:58:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrbHZho7K4WBH51EEznVGfkjPerj6MGl3vbAJeXASy5OP+CmBj5RZlqyj0ASB8iwRd8VTi X-Received: by 2002:a17:906:1187:: with SMTP id n7mr8290562eja.161.1595588306410; Fri, 24 Jul 2020 03:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595588306; cv=none; d=google.com; s=arc-20160816; b=QVt/jNXwOVhXF/hPki+V1Jwv9TX4pfyfzYo2NiOcDO5EuMQppEml8wU4MauDm8CjlV tY0Xf6Fgl/1x53aPytR/1Cq/k9UHJKwjg7ObEB5II4kx/wBcNcT5Mpp7KcvnMB5Fkv5T Kqeod8hx+gYlQCC5rWXjnCLA6kXWyh7Woad8ACVufuvUIk87YHqXThUOygCTew8WN/4n 0H8TZVZjNIVxHs1JIEXj/IMrjmLZlUwhSG4sx73IdhgaVAvWmooaz3TE0quJKmWffGhC uQxK0ZpKYw2LunGK/iPaMKL7+/tka8RHfq+YVU88kl43vKwNv6hel2hfLrZ9HZNd9kqU ffIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=dTI0RvYmB+fP73ftp8+VFu/GFD8sMlcrk0x3WCQYmQI=; b=ERfhQuguA6rq7fpKASFGsvhhNroDBbxNyfJwwO/TuESkbR+pETN4rJbvFFEAERYyw0 UIokfDvN5+KSf3W7NKBpKQ8QgQCRwnLtZ8Scg63UkXDYm00aEk8aI8a1HsEJaVR4zgbb h5mq3iC0k4AJ5iYMDfUPu8WGBpFapgbbxo7bLBHzBy63mktlBMsPaY0H50csIDQT3rfH gdCXKYFJTDTedjrPEhQvWGnVwQ75mgBi7WgRpMLGZDGixSIjHjW0ZZPQ3nk7cz46IzjR lBo3cGxwsrgEkncKC6YZZJanyhAFX6N332WId5Q8F10dPjTkj5hoo57LjOflqAZEgdfN Ybpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=rMlw0eEk; 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 n15si340597ejk.642.2020.07.24.03.58.03; Fri, 24 Jul 2020 03:58:26 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=rMlw0eEk; 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 S1726607AbgGXKzu (ORCPT + 99 others); Fri, 24 Jul 2020 06:55:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbgGXKzt (ORCPT ); Fri, 24 Jul 2020 06:55:49 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D7D5C0619D3 for ; Fri, 24 Jul 2020 03:55:49 -0700 (PDT) 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; bh=dTI0RvYmB+fP73ftp8+VFu/GFD8sMlcrk0x3WCQYmQI=; b=rMlw0eEkaKNDAz+lfekbBI0Z3+ usBKIbI7FDAJDFs0Sg/cDph9xhnpgYIKSLNVoMHX5M3EhGjTgJdQN4hSdu4Drx0upPjEenM9DEHO4 /uGLK/DgyWQzb/QOxpFxP6brhyiweIm/W6OfxPDQyh3+v2QJLoVKuAdAb1sNqaXJ/qX7Kkor0yMZn e+RjsYYIg1hn/YvnsnTNEX7RYsZIlTGBdLaoEA3txs0ADJ8veT7UA98FLjUPxZaakZvS1odKFp7// OU50s3WOieZW8B/s808/qjccOGEuNWfYxWFPjxggdM3Gwn1qPbjR6lxpR9IYqLdGHsfg+9tumstRa BHI7PBTg==; 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 1jyvMe-0005Ll-VL; Fri, 24 Jul 2020 10:55:45 +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 8CF5C300446; Fri, 24 Jul 2020 12:55:43 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6E66F2847BADA; Fri, 24 Jul 2020 12:55:43 +0200 (CEST) Date: Fri, 24 Jul 2020 12:55:43 +0200 From: peterz@infradead.org To: kan.liang@linux.intel.com Cc: acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, eranian@google.com, alexander.shishkin@linux.intel.com, ak@linux.intel.com, like.xu@linux.intel.com Subject: Re: [PATCH V7 07/14] perf/core: Add a new PERF_EV_CAP_COEXIST event capability Message-ID: <20200724105543.GV119549@hirez.programming.kicks-ass.net> References: <20200723171117.9918-1-kan.liang@linux.intel.com> <20200723171117.9918-8-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200723171117.9918-8-kan.liang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 23, 2020 at 10:11:10AM -0700, kan.liang@linux.intel.com wrote: > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 3b22db08b6fb..93631e5389bf 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -576,9 +576,14 @@ typedef void (*perf_overflow_handler_t)(struct perf_event *, > * PERF_EV_CAP_SOFTWARE: Is a software event. > * PERF_EV_CAP_READ_ACTIVE_PKG: A CPU event (or cgroup event) that can be read > * from any CPU in the package where it is active. > + * PERF_EV_CAP_COEXIST: An event with this flag must coexist with other sibling > + * events, which have the same flag. If any event with the flag is detached > + * from the group, split the group into singleton events, and move the events > + * with the flag to the unrecoverable ERROR state. > */ > #define PERF_EV_CAP_SOFTWARE BIT(0) > #define PERF_EV_CAP_READ_ACTIVE_PKG BIT(1) > +#define PERF_EV_CAP_COEXIST BIT(2) > > #define SWEVENT_HLIST_BITS 8 > #define SWEVENT_HLIST_SIZE (1 << SWEVENT_HLIST_BITS) > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 7c436d705fbd..e35d549a356d 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -2133,10 +2133,28 @@ static inline struct list_head *get_event_list(struct perf_event *event) > return event->attr.pinned ? &ctx->pinned_active : &ctx->flexible_active; > } > > +/* > + * If the event has PERF_EV_CAP_COEXIST capability, > + * schedule it out and move it into the ERROR state. > + */ > +static inline void perf_remove_coexist_events(struct perf_event *event) > +{ > + struct perf_event_context *ctx = event->ctx; > + struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); > + > + if (!(event->event_caps & PERF_EV_CAP_COEXIST)) > + return; > + > + event_sched_out(event, cpuctx, ctx); > + perf_event_set_state(event, PERF_EVENT_STATE_ERROR); > +} Ah, so the problem here is that ERROR is actually recoverable using IOC_ENABLE. We don't want that either. Let me try and figure out of EXIT would work.