Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp945226imm; Wed, 4 Jul 2018 08:37:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfZE3CAqE13mwopsBRcAwIHX//DLROndKJ9OzbkdcokM2pK1TFEryc5LfeaCvYiP7QDK59b X-Received: by 2002:a62:e903:: with SMTP id j3-v6mr2707168pfh.228.1530718660797; Wed, 04 Jul 2018 08:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530718660; cv=none; d=google.com; s=arc-20160816; b=d+vwjSTJ+FK0MmZmF2iATSfOxUR/KnM31DVPlmwku2VqgdXl9e+JWZWy/nDvVDEYtf KjvUQn6BtsX6UpVhvHtzjiVBl7Ma/BrxiPUxXEHMAD9wfu9sASTqLkYVN/pZnWCsadjV ZZZ07HTm266MzwOfjK8KyQJnC5peOdDFBlxDsn1SE4nqQOUbRHAzW2rluBKPtyN7k24M VKCnenWxfmhY1wBb9ARrJWaNU+OZRoNdXypxGJ6wmYzdj4aun+oHIufrgLLjOg/Zb5e4 xRiy30D7/V9iwTHMXjJ9l6vWVYbEJO3tzU0SBy8dKzvefJrgQ3x/vFjsiygfhExHtFfs pGag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=oclDJUKVFRwAWhy8jO3+HtV97HCGerAbxgROs1fAxkM=; b=P1hCAAJEJT2WS3QOD38Oqyka90AqkpSWCEguZIvndbMGOgy7XHqnaPrDkSzxWg0feo JV7WL86BYAb06J/IupZhbqOgOzXQ0IK4otDw8p9HKNMnw002/qpHfiWlTcHhohSB8D8r Aj/vhVNHHCtKF0ULUXAe9x+Md7l6w6DkJbAjRVx0YgOx3ShlVVLWna+37EL0OJ+Umki2 7jT0+zGgM8pxNg46QajIqZliMytt8zVNX5HGvqvBIscanF5FfRZ1Ru8HjyupAZbp6d+i n8A0RjOmJFHzQIJUQW55dLlUMjiUl77aAROV2iCZfeKeydsoe8FYNkmPx2/DCPOCwPFt 23bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IBezMTwc; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si3664715plk.441.2018.07.04.08.37.26; Wed, 04 Jul 2018 08:37:40 -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=@gmail.com header.s=20161025 header.b=IBezMTwc; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752844AbeGDPg1 (ORCPT + 99 others); Wed, 4 Jul 2018 11:36:27 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:45526 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752019AbeGDPgZ (ORCPT ); Wed, 4 Jul 2018 11:36:25 -0400 Received: by mail-oi0-f66.google.com with SMTP id m2-v6so11442288oim.12 for ; Wed, 04 Jul 2018 08:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oclDJUKVFRwAWhy8jO3+HtV97HCGerAbxgROs1fAxkM=; b=IBezMTwcvQR+YpdmDhOIok7wqFZyBl2v3fYdwaY8FoF80Q4GhDuhomEKIfu/oQGobp tu8cUdbxBSQ+IXJa09elAEdtxDPv90TWkrP/wB5H3Ay2RGyvQj8AIJ92v6eT+TuzQnzM e0dOiFUo2lGN6dYNAbVh29vCWJo8nz05xkOv8nBbHvQTJuYt0hRXsXl6megsoZS00+ga Rm+VzB151vHUka+mz+qf5nWmnyLkFI01Es2liZASj8PJfldT0B9KNFL9UgspAvBNE4f9 nl5ZI8DuK92PlcF0WlKhbeHlKACbds/x3zbbyhrgx6BUoZawcY0Pv6/PEUAXtRuKbDBF SVfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oclDJUKVFRwAWhy8jO3+HtV97HCGerAbxgROs1fAxkM=; b=ltAYam7zM3KO+muCp47URbvhleQksPagSYgyRzAUgRgp+Ylgqp0PqWmfkIctAAFf2V EGAoEM3fc00lF6wglxnmE08nw4ANVOoQu2AVmNnFE0olD9u8qmNQEQSAYNgsRExpMfjg NK+V2rfD0WTwzQJMV+sk4u3FTcBzmjsI4XDFZVnqJMe1gyMnKYzuAt5ZphsruJ6UFsPT k2H73xOy6jbwYatFge9CFMvnY08yZ1P23V+W6BE75QzsdYxyCx0mj9bscKA0sGX/woq7 u3q4lBg6sgfYR8zv4s8nELjk8BUT3msUZjbddDWjsMeEIiTg9lyijESXPJBn6h6E9q2G FCig== X-Gm-Message-State: APt69E2T9qtYGQiidvb/RKa0M7WRnuKyxKw2DcT9XcQ7rYw0dy6Z0HWF mO1pexEfwNhturoulAJ6tvc= X-Received: by 2002:aca:acb:: with SMTP id k72-v6mr2896953oiy.78.1530718585228; Wed, 04 Jul 2018 08:36:25 -0700 (PDT) Received: from localhost ([12.130.117.108]) by smtp.gmail.com with ESMTPSA id w40-v6sm3086677oti.80.2018.07.04.08.36.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Jul 2018 08:36:24 -0700 (PDT) Date: Wed, 4 Jul 2018 15:36:17 +0000 From: Dmitry Torokhov To: Yury Norov Cc: Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Kate Stewart , Matthew Wilcox , Philippe Ombredanne , David Ahern , David Carrillo-Cisneros , Andi Kleen , Jin Yao , linux-kernel@vger.kernel.org, Andy Shevchenko , Andrew Morton , Mike Snitzer Subject: Re: [PATCH 2/2] bitmap: sync tools with new bitmap allocation API Message-ID: <20180704153617.tps2asygskoym46d@penguin> References: <20180623073502.16321-1-ynorov@caviumnetworks.com> <20180623073502.16321-2-ynorov@caviumnetworks.com> <20180624213103.GA166241@dtor-ws> <20180624224522.GA23998@yury-thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180624224522.GA23998@yury-thinkpad> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 25, 2018 at 01:45:22AM +0300, Yury Norov wrote: > On Sun, Jun 24, 2018 at 02:31:03PM -0700, Dmitry Torokhov wrote: > > External Email > > > > On Sat, Jun 23, 2018 at 10:35:02AM +0300, Yury Norov wrote: > > > On top of next-20180622 and Andy Shevchenko series: > > > https://lkml.org/lkml/2018/6/18/841 > > > > > > The series mentioned above introduces helpers for bitmap allocation. > > > tools/ has its own bitmap_alloc() which differs from bitmap_alloc() > > > proposed in new kernel API, and is equivalent to bitmap_zalloc(). > > > In this series tools is switched to new API. > > > > > > This is RFC because I didn't find counterpart free() call to some > > > bitmap_zalloc()'s. So I didn't convert them to bitmap_free(). Could > > > someone point me out? The functions are: > > > setup_nodes(); > > > do_read_bitmap(); // Free is called, but only in fail path. > > > > Yes, because if we succeed we effectively return allocated bitmap to the > > caller. You'd need to trace upwards and see how it all gets cleaned up. > > But given that this is userspace and is not expected to be long-lived, > > maybe nobody bothered freeing memory and we instead rely on the kernel > > to clean it all up when process terminates. > > > > Thanks. > > > > > memory_node__read(); > > > > > > Signed-off-by: Yury Norov > > > --- > > > tools/include/linux/bitmap.h | 19 +++++++++++++++---- > > > tools/perf/builtin-c2c.c | 10 +++++----- > > > tools/perf/tests/bitmap.c | 4 ++-- > > > tools/perf/tests/mem2node.c | 4 ++-- > > > tools/perf/util/header.c | 6 +++--- > > > 5 files changed, 27 insertions(+), 16 deletions(-) > > > > > > diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h > > > index 48c208437bbd..b9b85b94c937 100644 > > > --- a/tools/include/linux/bitmap.h > > > +++ b/tools/include/linux/bitmap.h > > > @@ -98,12 +98,23 @@ static inline int test_and_set_bit(int nr, unsigned long *addr) > > > } > > > > > > /** > > > - * bitmap_alloc - Allocate bitmap > > > - * @nbits: Number of bits > > > + * Allocation and deallocation of bitmap. > > > */ > > > -static inline unsigned long *bitmap_alloc(int nbits) > > > +static inline unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags) > > > > This makes absolutely no sense for userspace API. What gfp_t even means > > here? > > > > If you want to introduce bitmap_zalloc and bitmap_free it is fine but > > adding dummy parameters to match kernel API exactly is a folly. > > Identical API makes easier porting the code from kernel to tools. > Refer for example declaration of kmalloc in: > tools/testing/radix-tree/linux.c > tools/testing/scatterlist/linux/mm.h > tools/virtio/linux/kernel.h > tools/virtio/ringtest/ptr_ring.c These are unittests for the APIs in question, of course they would have to match exactly. perf tool however is not a unittest, so there is no need to match kernel API. Thanks. -- Dmitry