Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp278565pxb; Sat, 21 Aug 2021 02:22:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcbtwCzHSflxmyNgfKhYZGs6jZ66imnRjUaIJnxT7nB8fYgv9uML3iBQPF0ndJtipLUiam X-Received: by 2002:a05:6e02:17cb:: with SMTP id z11mr1659604ilu.68.1629537735180; Sat, 21 Aug 2021 02:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629537735; cv=none; d=google.com; s=arc-20160816; b=0I6BShNIYddyl/RmBjsvc4t3KS2WJ9ggxfiiyxMUhaC1HRtQ/CyaKEzQirfUDiMTWH tpAn8cFsM7NjwvuM56v4Wn+XS4pwUKXCpZJVkAnrcJhLQeyptGeIP7ycoswl4fMG7vzp zuM1Pkgx30/6f+StRWsX5zTOQ3EcnakcD9shSmsgYhAwxtyAKgw8SfbSNDH1lv0MZ9cr usOALgjmwqJctTpRs6f6rwIDhr5Wr6GAxN5KiL255n09GH12I2OkSFQKltAfvVGeyhqP MVKdY0ymZzKwWv37XpUY8ziH9I4BIo5DyZ06SSGMg4nvpDkwfKmJMBtMY04rWaStNswE z26A== 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 :dkim-signature; bh=N+nB96fRRhC53bAnF/MrlsVfe1VX/CDYmRy1kac/YlM=; b=Bb76p/qCyLDKSIeGtspF0daCqV53J2xmbFJg+BhvaN539/y/E/66Hg9OprDywzgyqp ywONNaAVBd3ZaCnRnOcos7NbNBKnZWhAoG081665+FCV/SJmIwWDlAKG2oI60SahL7CI O2ufpV72p1byIw+Wrg3HjDZ7Y2xTCCWbHIK4+sCk8sRuCee1NQ2sFa/FGlkU4CwFJhA+ ofXguO5gAKLk1c96vx3Qfl6iqJLUPzUI/Uy1BbTJA80VsSLwyd/n/eTYEvpaG6YwN3oH ZsHIOBXm4vSeW8+pYObA9fZa+WZw1xuYtM+NyTqMpn99NIqvNneovKNedtujqJUKIC2b vGRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UeWjhOKT; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si8403225ioq.2.2021.08.21.02.22.03; Sat, 21 Aug 2021 02:22:15 -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=pass header.i=@gmail.com header.s=20161025 header.b=UeWjhOKT; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233811AbhHUJUj (ORCPT + 99 others); Sat, 21 Aug 2021 05:20:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233736AbhHUJUc (ORCPT ); Sat, 21 Aug 2021 05:20:32 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 648ABC061575; Sat, 21 Aug 2021 02:19:53 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id dj8so17662535edb.2; Sat, 21 Aug 2021 02:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N+nB96fRRhC53bAnF/MrlsVfe1VX/CDYmRy1kac/YlM=; b=UeWjhOKTJ6BHy7tzxslYFw7fz+/yWLcuxUdQmQimsGL+iLQ3RVtyUdWpUmXVZ9gt+s 2QYwCffKwklia9A73rJMbGdpvH/gImOT3KNGnuVQ1VozjMdXrzVGH1/2DpNhf+VGeoju XeFWkjXjvud6NqzjKlHa4OiS3oCYbjTPLWm5MXbfDuxV2oTT4O2sNcvLjBcoy3CmY1uX +bYnvjwJkZf5/O3H8XA4avMZ9tjlOO3cI/awoviknHU8/KYlr1AlJJqO7QCWslzTrJyB 5fT9ueXPCwSgr4knh/t+dLdnISxSwDnsVnhB3neq+hXd0OgZFfCeGJ2d1+L/BoJVO+iV 6pQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N+nB96fRRhC53bAnF/MrlsVfe1VX/CDYmRy1kac/YlM=; b=CKJmyCAFlOUqdE53+eUxuXncCokX68KLFAyUYfu2eiZEd5bK9G/kaXZfJPb5sObvCj cCYgEq7hcIjxXMMWGZP4QU4mTjB+grgwrF7an4gfI07iSQ/iA2E5ZxPrwQkuHHLmVGU0 8iAr+tYJf1lLI0NAfDwaG9E0+RqROx5GKFsVcLLe0OhVWOVtjh4fulcZKAQvGKVpr4bn rf+ceTdY+9VcE3qdgJ1ccknUpv6SWkEFfrM9Lg6wQnR/gXjLqfm/F0cHHBlrhMjScrwl 3nhiPPi+oVxYMJQuxr37xCm820UNv/E9ADg4RsZbnXGxOVuWaxac3qE4wUz7qR7CuRea aY1w== X-Gm-Message-State: AOAM533ZLzv7IoyT38Ov82Iq/U27k4ASQxxlgFuampheiYUV3vmFM3bR /mPQAkIoEhwL/vrtSeKmIY0= X-Received: by 2002:a05:6402:7ce:: with SMTP id u14mr26542422edy.61.1629537591966; Sat, 21 Aug 2021 02:19:51 -0700 (PDT) Received: from honeypot.. (mob-176-243-254-204.net.vodafone.it. [176.243.254.204]) by smtp.googlemail.com with ESMTPSA id a25sm4003878ejv.91.2021.08.21.02.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 02:19:51 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Riccardo Mancini Subject: [RFC PATCH v1 04/37] perf util: add mmap_cpu_mask__duplicate function Date: Sat, 21 Aug 2021 11:19:10 +0200 Message-Id: <8943a548ef7a3dd3e015095afad7e9a8b2154c05.1629490974.git.rickyman7@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds a new function in util/mmap.c to duplicate a mmap_cpu_mask. This new function will be used in the following patches. Signed-off-by: Riccardo Mancini --- tools/perf/util/mmap.c | 12 ++++++++++++ tools/perf/util/mmap.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index ab7108d22428b527..9e9a447682cc962c 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -350,3 +350,15 @@ int perf_mmap__push(struct mmap *md, void *to, out: return rc; } + +int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original, + struct mmap_cpu_mask *clone) +{ + clone->nbits = original->nbits; + clone->bits = bitmap_alloc(original->nbits); + if (!clone->bits) + return -ENOMEM; + + memcpy(clone->bits, original->bits, MMAP_CPU_MASK_BYTES(original)); + return 0; +} diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index 9d5f589f02ae70e1..b4923e587fd7749c 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -63,4 +63,7 @@ size_t mmap__mmap_len(struct mmap *map); void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag); +int mmap_cpu_mask__duplicate(struct mmap_cpu_mask *original, + struct mmap_cpu_mask *clone); + #endif /*__PERF_MMAP_H */ -- 2.31.1