Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp34153rdh; Tue, 13 Feb 2024 08:35:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUiF3mk+C46z1ceWguqXemvRLipdczNiWe3yRUXLRPiGKPR6b0+rwGEQfJ9+aSInci86a5l5bkGKv2fnHZC9skRMTW1xgpcSWjQ33lyOA== X-Google-Smtp-Source: AGHT+IE4ttAk7nOZCvkXhxIjkXpkxJDPKjxOjONCQ5hg7KcT1N526MGYSVLfjcJPRUPsr2XEHiNe X-Received: by 2002:a17:906:c44d:b0:a3c:b7d5:22dd with SMTP id ck13-20020a170906c44d00b00a3cb7d522ddmr4238409ejb.33.1707842132939; Tue, 13 Feb 2024 08:35:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707842132; cv=pass; d=google.com; s=arc-20160816; b=KJCfITSE3GO/qHZhBdlgpCu3PzoIkVgXcQumM6za5eqF/7IGvorWIs+rDy5BIBXZ5x skk1hvq9Ucrm29Tw59DWyZTtjnTzzmiFhN1Ha7t3c+/hGXqI791I7RHpIz583y+8NlFL JbrPS6NuPq3vuq8UMCP/k3QvDwxQIkMnJfswz7o2ST6z+Vmg9JxweCoPzu5jZIsFmJl0 w3PMkJuSHzwVn5DLuo4L92bOgVdcX1upuHZbc8YQWxnU53IjDhPUbQ6Qdyt3POudqe2W s+747k/xCea5Fkb75dLws2WjXjtVXGONPsQqOZtpX8LeExWC6Zc1Qun9YFmOiSyWKhDO dweQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=V4Ul6/u8/doIllpoT2jus1QLCDJfOp9pa0gFghmyPKI=; fh=JDpMSgnV647fzKb7K1e61Sg4Qx4USXEi0VnT8KhBkgg=; b=FNQWWQXZ9+58/tU3xlGICxTbAJ/Or3BiUJiwdZkVROd+wQ9WleSfllte7+6VfZfnKI 74NMw+0t7CueQ6yDBjqPecnd9o2oOn6xzY8v+7q+f4iotWEfk2Ix7GVZqRVv4r16w+Ez rhE9TOdFRJSrHdXl0YgHIAx+jbPM9U8FZMOdgV8leE78t7cutZc1inPgHnp3b2B2OBea 4VIDDZilY1ZfqxiVLnaxwdhFGLU/4zQ23YvaLnFM0GGZeEIa0yaJVRx/vhAxV/QroRuZ su9Q3KRTxVLE1JJL15IsFw0U1Xj3Zw1ko5ftmMxMaAJyt2mW6PloZnr/tkmMgs2VTZPv 2Xsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jV2UfaHY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-63896-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63896-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWK5irf/l7JpW3yDuqBGpizBvO3TIGUOmPTtfVPK1fE3GmgV42I66pITswyVdQHz74SxU6jFAV6tWJM85a5MMZ6Z84eN7m/P6iHrMavYQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u12-20020a1709064acc00b00a3cf0ab9273si1035995ejt.1017.2024.02.13.08.35.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 08:35:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63896-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jV2UfaHY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-63896-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63896-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AF8C01F2711E for ; Tue, 13 Feb 2024 16:35:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD3801EB23; Tue, 13 Feb 2024 16:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jV2UfaHY" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6873D2919; Tue, 13 Feb 2024 16:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707842125; cv=none; b=d9rkDf7oN4c4l5ctyRsGxRSU1L8tC/xFHPzBCHVqDVgjVH7WQZirYpi+yChFRecsXQ94jk5ya29FleIo3OOFixa55kKTKAhTf7gQTEoEdNydPcdb2rdD6qXeIUu4wnwMlUcXBNaSkpqcEuFOVL2oM5xhcwk+YXHiMYSffLsd0no= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707842125; c=relaxed/simple; bh=YCcie0zAZHdXXCutJQ7kG+dvXcsnwrHdF2tff2UKPsY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=V0mVTWVJyrlX/1VHVwvarJg3A4/XXpFnpSX9r1/3980fYrBcLzDtDKXUL6iidWdK90ImybMUyfqxm+48hXBOdjDi05MURd6G7951uJvoPq6+3fpdHS58+2vqurDpCcd+03M/M3EBEqO75Ljfqn9XOw4ncZkTZby1zhnCaHW9uWU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jV2UfaHY; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707842123; x=1739378123; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=YCcie0zAZHdXXCutJQ7kG+dvXcsnwrHdF2tff2UKPsY=; b=jV2UfaHYT3SH/MCwi/2PMHXkh1KdmzezKucDfeK51AOBsrMmU0N12ab6 cK2hHRtUDCjbGgXqdBeQkimVWbowD5r4wiUqWmOJ02syLHPj0+EOazLQ7 i8IGjtdpmrzz4qEFTA/MmNgSC+wugUhQ45p+Y8Pet1Ohj2Tc/5XlCKgiz 4GMxw3n41fuHLg1zlFvN3li9acPi/OA1uQ2efIoGX6qmiZyfdsJY37tPv oHVNw5oq4aIpOFttHVV1fooCH/ad4UUr6um6BBncM6niNnbKv5yrBE2aj Ort4TCl9P/qcbexaR6BM/hnIUF+/OWDjpWGaQNXzNUv4OwDzRGrQA3GSt A==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="12405100" X-IronPort-AV: E=Sophos;i="6.06,157,1705392000"; d="scan'208";a="12405100" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2024 08:35:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,157,1705392000"; d="scan'208";a="3299363" Received: from arieldux-mobl.amr.corp.intel.com (HELO [10.209.91.178]) ([10.209.91.178]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2024 08:35:22 -0800 Message-ID: <967027adabdc8aa654cd788b21147427477a0f08.camel@linux.intel.com> Subject: Re: [PATCH] tracing: Have saved_cmdlines arrays all in one allocation From: Tim Chen To: Steven Rostedt Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mathieu Desnoyers , Mark Rutland , Vincent Donnefort , Sven Schnelle , Mete Durlu Date: Tue, 13 Feb 2024 08:35:22 -0800 In-Reply-To: <20240212191336.5c502f78@gandalf.local.home> References: <20240212180941.379c419b@gandalf.local.home> <20240212191336.5c502f78@gandalf.local.home> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2024-02-12 at 19:13 -0500, Steven Rostedt wrote: > On Mon, 12 Feb 2024 15:39:03 -0800 > Tim Chen wrote: >=20 > > > diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_s= ched_switch.c > > > index e4fbcc3bede5..210c74dcd016 100644 > > > --- a/kernel/trace/trace_sched_switch.c > > > +++ b/kernel/trace/trace_sched_switch.c > > > @@ -201,7 +201,7 @@ static struct saved_cmdlines_buffer *allocate_cmd= lines_buffer(unsigned int val) > > > int order; > > > =20 > > > /* Figure out how much is needed to hold the given number of cmdlin= es */ > > > - orig_size =3D sizeof(*s) + val * TASK_COMM_LEN; > > > + orig_size =3D sizeof(*s) + val * (TASK_COMM_LEN + sizeof(int)); = =20 > >=20 > > Strictly speaking, *map_cmdline_to_pid is unsigned int so it is more co= nsistent > > to use sizeof(unsigned) in line above. But I'm nitpicking and I'm fine= to > > leave it as is. >=20 > I was thinking about making that into a macro as it is used in two places= . >=20 > /* Holds the size of a cmdline and pid element */ > #define SAVED_CMDLINE_MAP_ELEMENT_SIZE(s) \ > (TASK_COMM_LEN + sizeof((s)->map_cmdline_to_pid[0])) >=20 > orig_size =3D sizeof(*s) + val * SAVED_CMDLINE_MAP_ELEMENT_SIZE(s); >=20 >=20 Looks good. This makes the code more readable. Tim