Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp562518pxf; Thu, 8 Apr 2021 08:33:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsQCrklKgGQs2cJfkXrLkGJGPXC81QRsXTEX/2LdORT4KXHQHHmV3fhwMsoOLE8iLEryB0 X-Received: by 2002:aa7:8d5a:0:b029:227:7b07:7d8b with SMTP id s26-20020aa78d5a0000b02902277b077d8bmr7855840pfe.26.1617896030940; Thu, 08 Apr 2021 08:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617896030; cv=none; d=google.com; s=arc-20160816; b=J+PBDB9eIeMgCge/6OyZurEjxV3QIUwa6bppSmYfApn/F0PpwnNXGKe0zDc1un19yj GEVKLRvUsBeKWqdH2oSk3t1fGNKQadu9hU46ESc4WDou/rry7QtpjTjYv/Zm6W6XeYBv aTXlXHbXUHoJAqR+BInmG312Z4bTqXwk52VEY6WhrLvbCO/wzmjDZC6HVMPopIuxxvn7 NLrz7A+gSG8e8FdD8cDTWUOXEp5O/xC2UrYH1UHECiSPtsbk15j+1YZzIt4DHZNGMGj3 9MSwh5rOAtskRUC6H1VEjsA7gl7B4WRkfcZEzeQis/qcckiZG80siLp4mc7WY7QkCPLx j4kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=P97cSM9usgg4+asmUtC3WSyY4+g4DpJ+2YikpS0z6Us=; b=Jd1uEP0HOZv2p3MDQbHEnvCAr70qRIOWR6zu4APdxzc4xgI3FHLZk3rKNjifGlDiUG pmocK3MeZ1qbPvx7QZrmPIOTydrCd1NJsE6hLZBONLpgxP/fUFGnIkfYtoYAWga5qszI BS2ZRNwSQYk/N7f4qStgXPjaZiwh9AEpYYzoRX1tgYo5tbMFDvcxsW9nuDCLL1Y74vsd UfS5gbs+ZyYAeEasImE5bjfA4YVFdrjvnkbUhbUGJp+1MFUbyelsfuM1143J4zkjMkYF wyU1AQ0M+cN/82IHBrM1r+ehVE7a6rtwDJfOb9DvlvpqXNqFz/0hyZqUAX3g+uNDl2jF boxQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si26098180pll.329.2021.04.08.08.33.37; Thu, 08 Apr 2021 08:33:50 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232090AbhDHPcS (ORCPT + 99 others); Thu, 8 Apr 2021 11:32:18 -0400 Received: from mga04.intel.com ([192.55.52.120]:22953 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232076AbhDHPcS (ORCPT ); Thu, 8 Apr 2021 11:32:18 -0400 IronPort-SDR: c+xMjjox4aJEIFEv8SUxaKjq865tKKNAcemf/xoEiJv6eTCjIrOsRlS8Ok5AFSth0awBW9s0PW CxaykZofgEdw== X-IronPort-AV: E=McAfee;i="6000,8403,9948"; a="191412377" X-IronPort-AV: E=Sophos;i="5.82,206,1613462400"; d="scan'208";a="191412377" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2021 08:32:06 -0700 IronPort-SDR: 7bGg8xsEMCw6+7w7GiwnDYc8yCvI741S4oX4Cg4wcDYrwR6k/SxayRZfvm6Ae4y/uskF/Zapz4 FpB0zNw5C87Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,206,1613462400"; d="scan'208";a="415820729" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 08 Apr 2021 08:32:04 -0700 From: Alexander Shishkin To: Peter Zijlstra , Arnaldo Carvalho de Melo , adrian.hunter@intel.com Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa , Mathieu Poirier , Alexander Shishkin Subject: [PATCH 1/2] perf: Cap allocation order at aux_watermark Date: Thu, 8 Apr 2021 18:31:58 +0300 Message-Id: <20210408153159.81880-2-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210408153159.81880-1-alexander.shishkin@linux.intel.com> References: <20210408153159.81880-1-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, we start allocating AUX pages half the size of the total requested AUX buffer size, ignoring the attr.aux_watermark setting. This, in turn, makes intel_pt driver disregard the watermark also, as it uses page order for its SG (ToPA) configuration. Now, this can be fixed in the intel_pt PMU driver, but seeing as it's the only one currently making use of high order allocations, there is no reason not to fix the allocator instead. This way, any other driver wishing to add this support would not have to worry about this. Signed-off-by: Alexander Shishkin --- kernel/events/ring_buffer.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index bd55ccc91373..bd94b91bd4be 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -674,21 +674,26 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event, if (!has_aux(event)) return -EOPNOTSUPP; - /* - * We need to start with the max_order that fits in nr_pages, - * not the other way around, hence ilog2() and not get_order. - */ - max_order = ilog2(nr_pages); - - /* - * PMU requests more than one contiguous chunks of memory - * for SW double buffering - */ if (!overwrite) { - if (!max_order) - return -EINVAL; + /* + * Watermark defaults to half the buffer, and so does the + * max_order, to aid PMU drivers in double buffering. + */ + if (!watermark) + watermark = nr_pages << (PAGE_SHIFT - 1); - max_order--; + /* + * Use aux_watermark as the basis for chunking to + * help PMU drivers honor the watermark. + */ + max_order = get_order(watermark); + } else { + /* + * We need to start with the max_order that fits in nr_pages, + * not the other way around, hence ilog2() and not get_order. + */ + max_order = ilog2(nr_pages); + watermark = 0; } rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL, @@ -743,9 +748,6 @@ int rb_alloc_aux(struct perf_buffer *rb, struct perf_event *event, rb->aux_overwrite = overwrite; rb->aux_watermark = watermark; - if (!rb->aux_watermark && !rb->aux_overwrite) - rb->aux_watermark = nr_pages << (PAGE_SHIFT - 1); - out: if (!ret) rb->aux_pgoff = pgoff; -- 2.30.2