Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp4190rdb; Wed, 29 Nov 2023 17:36:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGESYMpbwEO9DXVQC4QQdRI/VRZOXOEP0Z3+PvQ4BW9Vu6OcnWjscjq0UygwrAm63mQE2kV X-Received: by 2002:a05:6a20:841e:b0:18b:4f8b:5a05 with SMTP id c30-20020a056a20841e00b0018b4f8b5a05mr29249046pzd.30.1701308215124; Wed, 29 Nov 2023 17:36:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701308215; cv=none; d=google.com; s=arc-20160816; b=TA2QdL3ZZmnwoBt1oIHobW0F9xQHPbyrlPNYlg8lbJU3czCH98fGhXhbfkZMQPjEuE RLm9AlVmxo2ndFICQ613mxUrsJ4O5DGp1gmEo/HBVCIcMoBj8Y31U6vOOHJM7emC9ad7 BFsjzt8SbnNI1PhOPIgRQ0/AHrIv0/zqA8PlIds6j5JGq4tTpeN2hxzKizORRv/JiBOJ AsKC8a1XZdmZ2MbLmboE4o/5BfaSzOJexoOyHSiSHZ2H6d0uC2wmUsTzjP67ga1YY1gd dse1JGjH9UIw+SrF399Ae+Gy1N6Fyr1c+fvYw/NMjNXOaYpWAlloxfpSOwTeVGAbVRmo l48w== 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=pQ60kNbXy8gMBc1nS+5kiw+gTOvHTIeKk+agfUPslvU=; fh=aWa9tyepd0GWyBFjkZa5ys7uNwpZ1AjfSj0Mu1iuQbE=; b=hM1JJvUFn051KzEPbdqNRgsQdv2QYPmQn/HRL9JduLtDwUYum/I14ExPBCdPfWhdvx 86V694StMraitWaJqD4h3ztzucMYPXZ2XJ3xE4P7mgz9s/0X9xtHuAu3q/rxXlBFZAIi 8q9ge1kWAM9bmI7p4VDvbLhzVb+q1tFPf/O7D/mph2ydZ1Y51SC9/jbj5NBoiiTZd6nq 8OFjO29un94W16deFqNz7BeLEhnmFOXBUM8J8kkWiu7IR6rYTrlPluK5OE6gmuNDxnGV BXaHkNORweJA0cvmF/YT8X9fdajQpIVdivRqy6caOc/evmhjtQzix/YpCyQHA4sjAG1d vXgg== 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 p4-20020a634204000000b005c21363f9b0si132348pga.766.2023.11.29.17.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 17:36:55 -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 EFDB6803C697; Wed, 29 Nov 2023 17:36:51 -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 S230393AbjK3Bgg convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Nov 2023 20:36:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjK3Bgf (ORCPT ); Wed, 29 Nov 2023 20:36:35 -0500 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D0FA1A3; Wed, 29 Nov 2023 17:36:42 -0800 (PST) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2855b566683so1308749a91.1; Wed, 29 Nov 2023 17:36:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701308202; x=1701913002; 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=K8Oujw9Wuea/rLA/FjXFwS/JqnACIhUyo3AE9Vp7Fp0=; b=quep10pAqKXRwAtzIGV8/Y4BZrXi3EnhrJuw4AXSqOYkasFoHH8ajyxBZE/82tGnoq PfOFLXBJl9dtJnMInVqpvfc1sLosEysIWBSX1/Ibw+3oZYTbwNvAt773DE6NA2XkYJkr aHU6inj9rW+GswttrtqGQk4/5oiSmFzMLAA9xiJhnMk23C9Ka0WNGlPqHsto1w5jqsLs Jrz+RNcN1DDTRsHATkRZLjBeJ1B0tjkG1AVXUFSL+H6T+ijdLfw+a7OyIeJcP6ym1wKb fyPkC2NnMuWS7PT5sbWqIuRuCGOsNtlnCHuXxQmSkmnKUYf+V13/1SA9omT80+7ixoXT AaxQ== X-Gm-Message-State: AOJu0Yz7BDrsbP+5Dx8sQa/FqrIfhRgCBqN0IdtxZOadFUR8FgSYwjUi mv9oyOgqBRRUwGMavjDdw42ZjaTyQkmW+rFBVoI= X-Received: by 2002:a17:90b:1d09:b0:281:d84:a97e with SMTP id on9-20020a17090b1d0900b002810d84a97emr29201239pjb.2.1701308201546; Wed, 29 Nov 2023 17:36:41 -0800 (PST) MIME-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> <20231127220902.1315692-5-irogers@google.com> In-Reply-To: <20231127220902.1315692-5-irogers@google.com> From: Namhyung Kim Date: Wed, 29 Nov 2023 17:36:30 -0800 Message-ID: Subject: Re: [PATCH v5 04/50] tools api fs: Switch filename__read_str to use io.h To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Nick Terrell , Kan Liang , Andi Kleen , Kajol Jain , Athira Rajeev , Huacai Chen , Masami Hiramatsu , Vincent Whitchurch , "Steinar H. Gunderson" , Liam Howlett , Miguel Ojeda , Colin Ian King , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , Ming Wang , James Clark , K Prateek Nayak , Sean Christopherson , Leo Yan , Ravi Bangoria , German Gomez , Changbin Du , Paolo Bonzini , Li Dong , Sandipan Das , liuwenyu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio 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]); Wed, 29 Nov 2023 17:36:52 -0800 (PST) On Mon, Nov 27, 2023 at 2:09 PM Ian Rogers wrote: > > filename__read_str has its own string reading code that allocates > memory before reading into it. The memory allocated is sized at BUFSIZ > that is 8kb. Most strings are short and so most of this 8kb is > wasted. > > Refactor io__getline, as io__getdelim, so that the newline character > can be configurable and ignored in the case of filename__read_str. > > Code like build_caches_for_cpu in perf's header.c will read many > strings and hold them in a data structure, in this case multiple > strings per cache level per CPU. Using io.h's io__getline avoids the > wasted memory as strings are temporarily read into a buffer on the > stack before being copied to a buffer that grows 128 bytes at a time > and is never sized larger than the string. > > For a 16 hyperthread system the memory consumption of "perf record > true" is reduced by 180kb, primarily through saving memory when > reading the cache information. > > Signed-off-by: Ian Rogers Acked-by: Namhyung Kim Thanks, Namhyung