Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1929104rdb; Sat, 2 Dec 2023 15:57:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0a8svdFTYowFi4aPGRyVyFFX+Vod8bq5n1rBKlc63oPogS3WWWr4W7k7Ej8Ej5fXHx1Ks X-Received: by 2002:a05:6808:10c4:b0:3b8:3fbe:5a0c with SMTP id s4-20020a05680810c400b003b83fbe5a0cmr2761453ois.11.1701561443326; Sat, 02 Dec 2023 15:57:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701561443; cv=none; d=google.com; s=arc-20160816; b=N6ugXtzr8+L4QGyeHhRbU14mrD96emVk2uoyCDrotadMQQZfrQVRFyxt0jlsK3Uez5 Abj5mz+B4H9dkXaw+cINZkNt8fZxtKHqca2xfOyqVJ4XMDjE27ITX5wUYzF8avtrfg11 9359QDNm7Xrlg1V9ok1PMwzMG3jTH2tBmbuOclxQ4o58ARsETd3Q9N3LFYGtxu/q0RGM hrNiW6MSJwOScfTNrPxBQy9KUx1PtXocaVb+3esYcbodgRhA9rKd9FQNakXuTjVPlETD AB2e9F5Vkzrux4tHbo2c3nrkFTylHknndeZBqJI4YLeP4JvMa5o0MviNwXg9aZGAUMpA HHMw== 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=vrFA23OomYyLBoRT2lVimiWVnTorqlbQc6NUhyu6zIY=; fh=aWa9tyepd0GWyBFjkZa5ys7uNwpZ1AjfSj0Mu1iuQbE=; b=PDJAx8FSkwW/tcUnuzOnofLpZqK0WOyATz3q5WjC6szNHXMlAD7aOSoLqSOCJaO79T LwW+mvB2LUmhwqyYwmOVB8PrY72mqjQeGcn7GKWvfwv52kwQBrfGZ3OPGmADJNU5Bh7C WlJEhi5tZggVOUfI8m5+yrjHeDXQem9/bxSzOdSPeaobxcW/kYAGoIhA60bayTAj10vB 0YPul2UC7w/9NiPTDM9NPxOURi4l1BX44oKEvP/xD8fyRVkn39sspfpVpabaqqPS9i8F 8Oc9liI1cQmVBh4SSJ9ekPSsDvoEJ9tgO7itgNBkdDwGNEkanqLOFNA7RVq63LPo/qlE 4xiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d15-20020a65620f000000b005b8eaeabf49si5721625pgv.178.2023.12.02.15.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 15:57:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 4329B805E41E; Sat, 2 Dec 2023 15:57:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231491AbjLBX4z convert rfc822-to-8bit (ORCPT + 99 others); Sat, 2 Dec 2023 18:56:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLBX4y (ORCPT ); Sat, 2 Dec 2023 18:56:54 -0500 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 842CDC8; Sat, 2 Dec 2023 15:57:00 -0800 (PST) Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-58e30de3933so161782eaf.3; Sat, 02 Dec 2023 15:57:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701561420; x=1702166220; 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=dyAFX5VXBNLiHxSUJrFaDK1h2Fd8kYr2nkmMBD96klk=; b=nyLE8eGts8o1gZtnxXDKop+gHfI9GfKD5FVATuhA5ovkRXyJdsbviah2rCwgLytfJI Tcen5yRkuQUG9g334YrPAPuFumU6BU12zJl2Xl4sEHe0iy3v7cNO6DVFRUQRGLpOBkZL EThsFcuDbgM/Vlf95ykrOGx4FNFslZEabS0yuZFxPfFViRL/+8xaDYVEwbzE+HHPEqoO /8Jw+4jChcFoKyXwUB4p6X0i3BwTVd4nziXfHmXMZE7/AX0rlreexS5Ed6+nbe9Q6XQB uLkRzNbM5tm+z3MQELeD0m2iP+oIYJCM3LNt+OZwiWiOPFxfMkXi5ES/uelJFhNSTdHf ZhDg== X-Gm-Message-State: AOJu0YzXTkJNsyvDFvor7cQ0+0SpNNEMTC2kUPItAzVkmy2Q3fFuU6YF iZ4qvTqghlJN613RxKb6LL7n0CctAC/aAej52wk= X-Received: by 2002:a05:6358:5e14:b0:16f:ffd6:7cd3 with SMTP id q20-20020a0563585e1400b0016fffd67cd3mr2207633rwn.6.1701561419684; Sat, 02 Dec 2023 15:56:59 -0800 (PST) MIME-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> <20231127220902.1315692-9-irogers@google.com> In-Reply-To: From: Namhyung Kim Date: Sat, 2 Dec 2023 15:56:48 -0800 Message-ID: Subject: Re: [PATCH v5 08/50] perf record: Be lazier in allocating lost samples buffer 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 agentk.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 (agentk.vger.email [0.0.0.0]); Sat, 02 Dec 2023 15:57:17 -0800 (PST) On Thu, Nov 30, 2023 at 10:29 AM Ian Rogers wrote: > > On Wed, Nov 29, 2023 at 6:09 PM Namhyung Kim wrote: > > > > On Mon, Nov 27, 2023 at 2:09 PM Ian Rogers wrote: > > > > > > Wait until a lost sample occurs to allocate the lost samples buffer, > > > often the buffer isn't necessary. This saves a 64kb allocation and > > > 5.3kb of peak memory consumption. > > > > > > Signed-off-by: Ian Rogers > > > --- > > > tools/perf/builtin-record.c | 29 +++++++++++++++++++---------- > > > 1 file changed, 19 insertions(+), 10 deletions(-) > > > > > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > > > index 9b4f3805ca92..b6c8c1371b39 100644 > > > --- a/tools/perf/builtin-record.c > > > +++ b/tools/perf/builtin-record.c > > > @@ -1924,21 +1924,13 @@ static void __record__save_lost_samples(struct record *rec, struct evsel *evsel, > > > static void record__read_lost_samples(struct record *rec) > > > { > > > struct perf_session *session = rec->session; > > > - struct perf_record_lost_samples *lost; > > > + struct perf_record_lost_samples *lost = NULL; > > > struct evsel *evsel; > > > > > > /* there was an error during record__open */ > > > if (session->evlist == NULL) > > > return; > > > > > > - lost = zalloc(PERF_SAMPLE_MAX_SIZE); > > > > To minimize the allocation size, this can be > > sizeof(*lost) + session->machines.host.id_hdr_size > > instead of PERF_SAMPLE_MAX_SIZE. > > Sounds good, should probably be a follow up. The current size is > PERF_SAMPLE_MAX_SIZE. Yep, I'm ok with having it as a follow-up. Acked-by: Namhyung Kim Thanks, Namhyung