Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp956698ybi; Fri, 21 Jun 2019 11:03:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfvhOevMrSu8Xj76v3sCMUACQI9p9oRNl23a1x98D5Lq2t1iDi2lHdwHjhiN0KtETrctk3 X-Received: by 2002:a17:902:ba82:: with SMTP id k2mr127349135pls.323.1561140198575; Fri, 21 Jun 2019 11:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561140198; cv=none; d=google.com; s=arc-20160816; b=cIUZnlgeBjrO91Fstu6HP21ScMkDBzh6P5n1Ql9/CikgsbCsyasZYnIvXr0ZaxLFtQ fe1RSIO0Ae41gcOZPH41SzZ5D1b+Yb3Qp1uNaDo17GJdNNXFAexnhurUlNrvFcHuKYqZ nOkcz2rkNVX18+eknk/FfnHpqSGEZkkTmVJgJh1XSRsHZwC0jQ4pbJdlt+aLLLRc6iFq Ps1ARVratGv2ZokH/kX/+bKDmw7E/rcn+G0rH+Zf8fCTT1QPONsdoYBm1bmxZ0h2rGhx PcHtWJkINl8BcA9OLyuIZ6rCe+qPnMvo7odj+NNCJ2nvsyPwyUpWf1nFZrd5YIuGxmJh ZLCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KddSnqJk8N2HccW5lB3LKF7N+h2SRaXdd/fZu8Bc+Lk=; b=kIJpgX1G9vyv8aG5SlkXXUGUvLrC4OhqBVYaBr80FcHscvp1tTDsEaLwNO0eYZWkdz QuD6tLyb7MumpKQkFINl50NtXCgmEtVOKTzyYfMpuuqXvXKXjcESZ+PKDk8H5TRo/WjS hbJ8tbiZSE8NlmATjA3+9fJSYUTitYVMynrncr/aP53/AjMTGmTuhTiDRP4rQjPa0yZO cD0AXjXfW9w1dWiKI9MqAuP9kBX7+z3qWHYgW40PncDQ41HPT+HLFVBCz62Sn2ODDOg9 qcwYFT9xDu/Eb/Cjd8a7H//JH/P+SiSj4M2/PXiv8NBpgTTsGPleYR+hqgu0U3PwdP2Q zPyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YFiDyop6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 59si3432882plp.90.2019.06.21.11.03.03; Fri, 21 Jun 2019 11:03:18 -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=@google.com header.s=20161025 header.b=YFiDyop6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbfFUSBo (ORCPT + 99 others); Fri, 21 Jun 2019 14:01:44 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37504 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbfFUSBn (ORCPT ); Fri, 21 Jun 2019 14:01:43 -0400 Received: by mail-wr1-f65.google.com with SMTP id v14so7433267wrr.4 for ; Fri, 21 Jun 2019 11:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KddSnqJk8N2HccW5lB3LKF7N+h2SRaXdd/fZu8Bc+Lk=; b=YFiDyop64/iXrObHdO/Sgrip+DwxTbflll8pn4Cep0G8Iv7W9rRpxgMdPS77jFhOby iabgmfZsVJ1MLI8DaFurSwQC17KTT8Se54I4TioiBVkhKw8WSCoGkq4N8ERK6Y9Ov/l9 q9QTVbVkirEZsYwDXKZ6V8W051djxYse9oxxJVY3gJkS4Uu3dygzTGI0tVqRw+35JoyG +TcFIS3n2HH9KWx3KgWsaESaQR04QNHJPU0G6f/snPEDqmKaA9czthbG4Gso37ZtqR7B 4C32o1gzAcPlRMuxgsJpZxuH6uDkwaHqcYTsIKX/R8kYUBOg713j6F/IvaJSo/9yTowY fbKw== 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:cc; bh=KddSnqJk8N2HccW5lB3LKF7N+h2SRaXdd/fZu8Bc+Lk=; b=RBd2CSvoV384ag7nH5vUJnSm9BzOacz8zVsWJDIWrMzk//IQWf4A+EuivkkOlAtxPS O0bCoJ+csIfopfaigdPISVh9rXAgzN9yBISBF95UCp6Nl/cIN1e8mgZ+M5ED6VQYnGQG ph8p4kNz60JVYYjYZ+OQ4wfd+zLpG1hPxWOSeqM8kbv8onvrFslJhEOVrpLLR8C4hU3b /4vKPUKjKLh6qIrB8xvZGm4oNH5dTbk9sIAmNYoJJCrGh2nmDjq77LtCo2kuPp5gxZ8o JLp8WYRD84el4PrJRkFtXyR+so58I677k4FpmvyMetcR86qHMe9B9iW/HAzkTdjE/trV B9+w== X-Gm-Message-State: APjAAAWGY6/k0kuyywg3RMBKD/bOnNI+1vhMo7w6KQU7cCwqrqMUXicx nls2hiOrLuaoGyr78gCbcmd38eG6mJAFQT2boFu12A== X-Received: by 2002:a5d:49c4:: with SMTP id t4mr40662447wrs.318.1561140101725; Fri, 21 Jun 2019 11:01:41 -0700 (PDT) MIME-Version: 1.0 References: <20190601082722.44543-1-irogers@google.com> <20190621082422.GH3436@hirez.programming.kicks-ass.net> In-Reply-To: <20190621082422.GH3436@hirez.programming.kicks-ass.net> From: Ian Rogers Date: Fri, 21 Jun 2019 11:01:29 -0700 Message-ID: Subject: Re: [PATCH] perf cgroups: Don't rotate events for cgroups unnecessarily To: Peter Zijlstra Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , LKML , Kan Liang , Andi Kleen , Stephane Eranian 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 Fri, Jun 21, 2019 at 1:24 AM Peter Zijlstra wrote: > > On Sat, Jun 01, 2019 at 01:27:22AM -0700, Ian Rogers wrote: > > @@ -3325,6 +3331,15 @@ static int flexible_sched_in(struct perf_event *event, void *data) > > sid->can_add_hw = 0; > > } > > > > + /* > > + * If the group wasn't scheduled then set that multiplexing is necessary > > + * for the context. Note, this won't be set if the event wasn't > > + * scheduled due to event_filter_match failing due to the earlier > > + * return. > > + */ > > + if (event->state == PERF_EVENT_STATE_INACTIVE) > > + sid->ctx->rotate_necessary = 1; > > + > > return 0; > > } > > That looked odd; which had me look harder at this function which > resulted in the below. Should we not terminate the context interation > the moment one flexible thingy fails to schedule? If we knew all the events were hardware events then this would be true, as there may be software events that always schedule then the continued iteration is necessary. Thanks, Ian > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -2314,12 +2314,8 @@ group_sched_in(struct perf_event *group_ > return 0; > > pmu->start_txn(pmu, PERF_PMU_TXN_ADD); > - > - if (event_sched_in(group_event, cpuctx, ctx)) { > - pmu->cancel_txn(pmu); > - perf_mux_hrtimer_restart(cpuctx); > - return -EAGAIN; > - } > + if (event_sched_in(group_event, cpuctx, ctx)) > + goto cancel; > > /* > * Schedule in siblings as one group (if any): > @@ -2348,10 +2344,9 @@ group_sched_in(struct perf_event *group_ > } > event_sched_out(group_event, cpuctx, ctx); > > +cancel: > pmu->cancel_txn(pmu); > - > perf_mux_hrtimer_restart(cpuctx); > - > return -EAGAIN; > } > > @@ -3317,6 +3312,7 @@ static int pinned_sched_in(struct perf_e > static int flexible_sched_in(struct perf_event *event, void *data) > { > struct sched_in_data *sid = data; > + int ret; > > if (event->state <= PERF_EVENT_STATE_OFF) > return 0; > @@ -3325,21 +3321,15 @@ static int flexible_sched_in(struct perf > return 0; > > if (group_can_go_on(event, sid->cpuctx, sid->can_add_hw)) { > - if (!group_sched_in(event, sid->cpuctx, sid->ctx)) > - list_add_tail(&event->active_list, &sid->ctx->flexible_active); > - else > + ret = group_sched_in(event, sid->cpuctx, sid->ctx); > + if (ret) { > sid->can_add_hw = 0; > + sid->ctx->rotate_necessary = 1; > + return ret; > + } > + list_add_tail(&event->active_list, &sid->ctx->flexible_active); > } > > - /* > - * If the group wasn't scheduled then set that multiplexing is necessary > - * for the context. Note, this won't be set if the event wasn't > - * scheduled due to event_filter_match failing due to the earlier > - * return. > - */ > - if (event->state == PERF_EVENT_STATE_INACTIVE) > - sid->ctx->rotate_necessary = 1; > - > return 0; > } >