Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5031965rdb; Tue, 12 Dec 2023 17:34:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IESNjrF+7hoBNGnzXDWG76pQEs8Lw25ptRraFWvmird6TH62wtOE8uarIg1Y25YUoImUb7y X-Received: by 2002:a17:90b:3545:b0:28a:d568:98e0 with SMTP id lt5-20020a17090b354500b0028ad56898e0mr1174926pjb.14.1702431253654; Tue, 12 Dec 2023 17:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702431253; cv=none; d=google.com; s=arc-20160816; b=OSIGF1OZnveLODhHisOUpL1Bkoy52uMfQ6r3i1KN+lzUDLy/Bq7ClVHuZD0XH9mXgB eyYqAoXt4uYJ+wAmRzGrsOlzC2e6Z8sdQscC77PRlEBKDL0l1xluIWD1+Rr4SzTMAgU2 DPljbX/qvDpcHFP1x210SW09PVpv6yuR/jJ+YHVGX/KuMW0lXnfwo90uV9Sc0rRICrWL NtxbG32SPm4JJC8DxT79Osn0xd3FYT04W53kHfzcX96d5qXknlajxGxCCSmiCKcaB/Vb 3rLJFOFs9NCg3YjggtY1YqpLsPEWbHzW+YI/Rse9nQrdaHLAx1Ec1i2//NeZ99+KRc/e p+UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=JSSe1BQ6FEasN1fyctL90RbtGEceVe68DfX0hvQblBM=; fh=9QhaDQogLdawoxsWypKjVVByFXJdfqCA8m5VVhOPqGs=; b=tLM9Xs5xa8tW5vacgaDQ9r7Xnm+GHMH7HemlteU7oC/oe5ReleF+JbI05sfo0WDNen K3ZNrRBmRimMIbgAfVnrbUIqQu75wC+Aw2i1nbg1w8/2dPrT886P8ItUro3zNUnTykcQ bL/GPZY9uBprcJ3kYrXvhaMBBGABQ3uIcSLqNKjvOjObamZ6P9/3cYuct9xAb3z1GyKS D0HqmveET7wbFkNvuvKVzfPbqISO1ZtiUXlnYmKICYtG+WNAse1+XXPTrr/+5vsdoChc 1Kc7nm13YwqYNgyh3cCFhXtzRkqLY14RkEUClZOYzn7inkxL6X9uFPnOdHPh5vBQlmh3 VRWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id b10-20020a17090a800a00b0028065b30a0dsi9788106pjn.124.2023.12.12.17.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 17:34:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id F28D28075EC8; Tue, 12 Dec 2023 17:34:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378177AbjLMBdz convert rfc822-to-8bit (ORCPT + 99 others); Tue, 12 Dec 2023 20:33:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378145AbjLMBdy (ORCPT ); Tue, 12 Dec 2023 20:33:54 -0500 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A02FB7; Tue, 12 Dec 2023 17:34:01 -0800 (PST) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6ceb93fb381so4657121b3a.0; Tue, 12 Dec 2023 17:34:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702431241; x=1703036041; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nL8WQ6XQifHuAl5/6bibXSmjCD6Q0OYVm2RrMW20160=; b=Dj9xxVLGyJ/Ein3/G6+yxCuYRH9f8Koi2yNVSXQQDby3iEYadeA4hwiQmBs3N59/M4 VLiiJ9TKhqKdTLLyZkQPXxCsg+XTDobHkBtuBZ6LNjLJVOMYDCEsI5hwsFgZvtpVBTvt prcTFRRDdHufRGOM8fQqBhMEv7B2AOMu5yE99ysBT6CcJkax2Ylc4pMHH6cZyLup7BkB vSXpSEUvTFljQTOBUuZU8L+53XM9xup4245/ZkW71QeEoyfL4Lr4aKf9/jBEHsYkKEm+ cXyHEUfpuwOf9xeYPpwTTbtKeH/w7bJBqoRRUUtCBT8rTy8kixAV/9jBv76ZOSoxhAng 7Y/A== X-Gm-Message-State: AOJu0YzyZJwP70yxyG8YSAo19PqpbsJt2QnxnPK7jBAnuJEi8TdBfu/i nksalzl/QERBx6Os+AGmVSItm6ZFq+HPFEO+m3I= X-Received: by 2002:a05:6a00:2301:b0:6c3:4bf2:7486 with SMTP id h1-20020a056a00230100b006c34bf27486mr9484517pfh.7.1702431240694; Tue, 12 Dec 2023 17:34:00 -0800 (PST) MIME-Version: 1.0 References: <20231207050433.1426834-1-irogers@google.com> <20231207050433.1426834-3-irogers@google.com> In-Reply-To: From: Namhyung Kim Date: Tue, 12 Dec 2023 17:33:49 -0800 Message-ID: Subject: Re: [PATCH v1 2/6] tools lib api: Add io_dir an allocation free readdir alternative To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Masami Hiramatsu (Google)" , Thomas Richter , Quentin Monnet , Fangrui Song , Kan Liang , Yanteng Si , K Prateek Nayak , Artem Savkov , James Clark , Ravi Bangoria , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 17:34:09 -0800 (PST) On Mon, Dec 11, 2023 at 3:54 PM Ian Rogers wrote: > > On Mon, Dec 11, 2023 at 3:25 PM Namhyung Kim wrote: > > > > On Wed, Dec 6, 2023 at 9:04 PM Ian Rogers wrote: > > > > > > glibc's opendir allocates a minimum of 32kb, when called recursively > > > for a directory tree the memory consumption can add up - nearly 300kb > > > during perf start-up when processing modules. Add a stack allocated > > > variant of readdir sized a little more than 1kb. > > > > > > As getdents64 may be missing from libc, add support using syscall. > > > > Unfortunately my alpine build has: > > > > In file included from util/machine.c:2: > > /build/libapi/include/api/io_dir.h:17:23: error: conflicting types for > > 'getdents'; have 'ssize_t(int, void *, size_t)' {aka 'long int(int, > > void *, long unsigned int)'} > > 17 | static inline ssize_t getdents64(int fd, void *dirp, size_t count) > > | ^~~~~~~~~~ > > /usr/include/dirent.h:52:5: note: previous declaration of 'getdents' > > with type 'int(int, struct dirent *, size_t)' {aka 'int(int, struct > > dirent *, long unsigned int)'} > > 52 | int getdents(int, struct dirent *, size_t); > > | ^~~~~~~~ > > Presumably there is a #define getdents64 getdents .. Could we stop > caring about this version of Alpine linux? Right, there's a #define: https://git.musl-libc.org/cgit/musl/tree/include/dirent.h#n68 But I'm not sure ignoring Alpine linux is a good idea. Maybe we can add a #undef right before? Thanks, Namhyung