Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp543647pja; Thu, 19 Mar 2020 07:16:09 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtGQaYhyH345IPFABZirpT1qlxSAqGinMBO7lqmbG3fyzHcGHtGV3N/yf/2pfyK45dP3Hl3 X-Received: by 2002:a05:6830:1f0c:: with SMTP id u12mr2425028otg.59.1584627368947; Thu, 19 Mar 2020 07:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584627368; cv=none; d=google.com; s=arc-20160816; b=Zx1bhUhAYC7QlqHvngPPDyE3TfZ0XXBHJvu2TbAGlefOpamgntRz1ATLoXxl68Kp3X Wc8Eal9nsNIp79XVNHUprSs5bdWYeC1SxbhYhA+OfXNId5ZZNIB33I2M7TcxeLZxj9so 1CCGNpv21w4RynBrsKZwVJY5CHoNl8jMEwXFmSiHI+cY47lza1SdbuY9IOTljRrq+B0N +UtuFcbTNip+yLwlkYgOOcRR1qV6qBWGQ5aDV8eo0SZsnsAaI2Puj1S2OJ8gtSzE8zcm sUKgZFUbnHaHtFyH81Vb5m2+5EizH6kkEcIKnYACU5traxEN9adqvOfRnKCR4egI3sbO MpGw== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=O1lzF7zNMy3qG8jCjha3kRKXjYX+PPDT+UpOL8li/II=; b=TtYpSiTc1WwYgHkU6lrHjQViNN8HA7P87Nzr3fcqryQKYEsfyvCjp1/G5QSzIVXkpB z4SkUfJigT2XFJuzWIlpNn0V9spdNYBdHv896EXeKF3r3mXofAPDS8nWOtcNZ5bUuaWC x27ZXYBPUA1OAVzF3Ypscq/fFaQSZF9nD9qjn7peVoMDIs56Jzukxxd3glDT23HBvP1H z9k/MtAT3R0iwHD9b1hoH1kfUupqb8cHuH8nBC24Qm5S/XbJiZHT70j3crMd2UGgtm8R n1IshhwQpWWQqJdGylMBcSr1PFM7cDS6429B8uIyI9atMALCVesjMceao5ymZ3hYz61z i5kg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u199si1148340oif.110.2020.03.19.07.15.48; Thu, 19 Mar 2020 07:16:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727566AbgCSOKs (ORCPT + 99 others); Thu, 19 Mar 2020 10:10:48 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60804 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727533AbgCSOKr (ORCPT ); Thu, 19 Mar 2020 10:10:47 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jEvsf-00020F-Ry; Thu, 19 Mar 2020 15:10:41 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 823501C22A3; Thu, 19 Mar 2020 15:10:41 +0100 (CET) Date: Thu, 19 Mar 2020 14:10:41 -0000 From: "tip-bot2 for Alexey Budankov" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf record: Fix binding of AIO user space buffers to nodes Cc: Alexey Budankov , Alexander Shishkin , Andi Kleen , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , x86 , LKML In-Reply-To: References: MIME-Version: 1.0 Message-ID: <158462704123.28353.13994745078032026323.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: 44d462acc0bf3eabe1522471fd1f683d8ce612cb Gitweb: https://git.kernel.org/tip/44d462acc0bf3eabe1522471fd1f683d8ce612cb Author: Alexey Budankov AuthorDate: Thu, 12 Mar 2020 15:21:45 +03:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Thu, 12 Mar 2020 11:32:46 -03:00 perf record: Fix binding of AIO user space buffers to nodes Correct maxnode parameter value passed to mbind() syscall to be the amount of node mask bits to analyze plus 1. Dynamically allocate node mask memory depending on the index of node of cpu being profiled. Fixes: c44a8b44ca9f ("perf record: Bind the AIO user space buffers to nodes") Signed-off-by: Alexey Budankov Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/c7ea8ffe-1357-bf9e-3a89-1da1d8e9b75b@linux.intel.com [ Remove leftover nr_bits + 1 comment in mbind() call ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/mmap.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 3b664fa..ab7108d 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -98,20 +98,29 @@ static int perf_mmap__aio_bind(struct mmap *map, int idx, int cpu, int affinity) { void *data; size_t mmap_len; - unsigned long node_mask; + unsigned long *node_mask; + unsigned long node_index; + int err = 0; if (affinity != PERF_AFFINITY_SYS && cpu__max_node() > 1) { data = map->aio.data[idx]; mmap_len = mmap__mmap_len(map); - node_mask = 1UL << cpu__get_node(cpu); - if (mbind(data, mmap_len, MPOL_BIND, &node_mask, 1, 0)) { - pr_err("Failed to bind [%p-%p] AIO buffer to node %d: error %m\n", - data, data + mmap_len, cpu__get_node(cpu)); + node_index = cpu__get_node(cpu); + node_mask = bitmap_alloc(node_index + 1); + if (!node_mask) { + pr_err("Failed to allocate node mask for mbind: error %m\n"); return -1; } + set_bit(node_index, node_mask); + if (mbind(data, mmap_len, MPOL_BIND, node_mask, node_index + 1 + 1, 0)) { + pr_err("Failed to bind [%p-%p] AIO buffer to node %lu: error %m\n", + data, data + mmap_len, node_index); + err = -1; + } + bitmap_free(node_mask); } - return 0; + return err; } #else /* !HAVE_LIBNUMA_SUPPORT */ static int perf_mmap__aio_alloc(struct mmap *map, int idx)