Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp459512rbb; Sat, 24 Feb 2024 07:49:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvJIMBawpqX+I6Y1WaGjRo6k8/jOB5le3S0wlMuXnkLa5IGzzhQhD5SDIpfOooU4iTMR0MQ9dr/Z7By68/QfixMHyO9icq1WAanbr0Jw== X-Google-Smtp-Source: AGHT+IEBp53h2ERbC/9UbCnJhBHSSkVbgcNLiguDL8xDdfCXL6MoOeQwS8KFDrvm83tBEU3MBa2b X-Received: by 2002:a05:620a:b15:b0:787:9d04:9528 with SMTP id t21-20020a05620a0b1500b007879d049528mr3834417qkg.21.1708789786104; Sat, 24 Feb 2024 07:49:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708789786; cv=pass; d=google.com; s=arc-20160816; b=Ewy1seiDi8LxIPvy0vy5MuDYW221i41cR0KAVrQzx4nBX1NB6E9merg11+fsHwdbdq XgbBRg1H36EX9/WU16Ma0BBI5zmh79vc3GLsmV4c28iRCkFDndHONAtBDRh3gheWCR7r J2VNZYxF/WYauinzW5IMthtL4RQdG4ArcGLY77rmMf10rzhYwf9z5c9rDgpAxfIgUv3G MZOqUgBFRv3Hoyurxhfvg3cY0Ejq0dwAzd8S1JCVihKreebT1wPl4Ha/d5/dCUb+p/Ln hqtPOXqM/9fyi9N5vDyimbCD1i8jktKlksfxFzpjYKxeRRfypKUt9U48ldCkCVcFdCT4 JCuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=n4YfUdufMMX5Nr60snqa6axfgXFXmxQNdpwAL7IrojU=; fh=b3Zct6ep6f8qsskPQSL/7rAtRQDBx522hoQeDkqUoKg=; b=AoO2yfvEl7R/ZmZkqFL47RxI36w0OpxkEwOVmDiWVMlTGsrQ+xX7Nszs0lHuILi8ro R3BVS1z/293DaZnt0npMwZLXmTV32+uq9o2LqBKoXT+kosQrSwsou0+6YG1xasJB3Eeq gHxEnAn/MjuVhftu8cDA7FydwABic9eE6O7cYtYdEJf6s2qYmNJ/TXeZlKFsi1dQv/YW eU1wOvLCaWJEJJp+Ozhhfh9AWnP4oLNvL0REmOV19AZbxAiHAe/1QfbxdCwUqCF0HXKJ gpKwTjoA4WuADdMYf/nqFrT6my9dzRyCx5QLGG8eobpbDzIGgRXlP1DpAU/lJ6u/OADU YT6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CFgTMPRi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79728-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vq7-20020a05620a558700b00787bfa06efbsi1270789qkn.575.2024.02.24.07.49.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 07:49:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CFgTMPRi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79728-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D7F921C20CF5 for ; Sat, 24 Feb 2024 15:49:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A4E94779D; Sat, 24 Feb 2024 15:49:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CFgTMPRi" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3118E46558; Sat, 24 Feb 2024 15:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708789779; cv=none; b=ldrO6lNYaM7fTeXaZ05bpPDE2YOhQ3UT8CPLXbXvDF58kE1nmcEg0Cuyceh/9Vpd+usLzNU6MESdyqxSjBoNIXAlcP6K+QgGG3mtKZBndaGgLBa43PUSLCuQaVwVlxccbR+E4uTcbXljTFT6EM1rLzuYv0ud0PZPWftW+zAq1bg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708789779; c=relaxed/simple; bh=JhKIpi/5c6m6jLWrTAC+y0zdzh3KN93tgDycxt99TUg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cDHlot/zcgEEAOpPWlTDe1n9Xc04Sj60ZjHpuFpJosIcmgPRoxLkXAH3JYEiJK8B7rCWwZqa3o/bt0LGWuFMehxbn8C/c5OONpieP9HVtwcMARjtW6ent7FAbj/k3Ru372NdorjAD+xFVCpGuVx9IEi3coAMMJroJysW4v+AWJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CFgTMPRi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B40FC433F1; Sat, 24 Feb 2024 15:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708789778; bh=JhKIpi/5c6m6jLWrTAC+y0zdzh3KN93tgDycxt99TUg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CFgTMPRifsogZ8rVCApbX8LuzPxzgwkbz5lsW7bMS7exPBXVEBQfc4JXGpkeKqPH8 6DjhFtT1jvA73iACGTnkhu/OZLFVi1IVnt07el+S91xmqR91Fmvv1BZo0CeDs7bT+f EN1MZFlKX4h16gYYZFVjfZY4rYwMylTNj8eM0ADD0ka6Bl13WI0F16xcMHDYOPAO/5 5/HgRB1KPuyTEnwcJKkP3xGRFagQV+sv4/Cp/ti4EBwss+kuhT4+l0VhrdStxnEv37 nShK2i99e6JU5y4I5iCDXGPxEM+yQO+YB+0mXHfB0ypRrpAenoh0k42N51KuhxQifE trPDdkTaD58aA== Date: Sat, 24 Feb 2024 12:49:35 -0300 From: Arnaldo Carvalho de Melo To: Ilkka Koskinen Cc: Namhyung Kim , James Clark , Ian Rogers , Evgeny Pistun , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] perf data convert: Fix segfault when converting to json when cpu_desc isn't set Message-ID: References: <20240223220458.15282-1-ilkka@os.amperecomputing.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240223220458.15282-1-ilkka@os.amperecomputing.com> On Fri, Feb 23, 2024 at 02:04:58PM -0800, Ilkka Koskinen wrote: > Arm64 doesn't have Model in /proc/cpuinfo and, thus, cpu_desc doesn't get > assigned. > > Running > $ perf data convert --to-json perf.data.json > > ends up calling output_json_string() with NULL pointer, which causes a > segmentation fault. > > Signed-off-by: Ilkka Koskinen Acked-by: Arnaldo Carvalho de Melo - Arnaldo > --- > > v1: > - https://lore.kernel.org/all/20240111232923.8138-1-ilkka@os.amperecomputing.com/ > v2: > - Changed the patch based on James's comments. > v3: > - The architecture is checked from the actual data file to allow one to do > conversion on another system. (thanks to James for the feedback) > - https://lore.kernel.org/all/20240117215101.77713-1-ilkka@os.amperecomputing.com/ > v4: > - Made the fix more generic in case there are other architectures where cpu_desc > isn't assigned as asked by Namhyung > - Rephrased the subject line > --- > > tools/perf/util/data-convert-json.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c > index 5bb3c2ba95ca..09d57efd2d9d 100644 > --- a/tools/perf/util/data-convert-json.c > +++ b/tools/perf/util/data-convert-json.c > @@ -284,7 +284,9 @@ static void output_headers(struct perf_session *session, struct convert_json *c) > output_json_key_string(out, true, 2, "os-release", header->env.os_release); > output_json_key_string(out, true, 2, "arch", header->env.arch); > > - output_json_key_string(out, true, 2, "cpu-desc", header->env.cpu_desc); > + if (header->env.cpu_desc) > + output_json_key_string(out, true, 2, "cpu-desc", header->env.cpu_desc); > + > output_json_key_string(out, true, 2, "cpuid", header->env.cpuid); > output_json_key_format(out, true, 2, "nrcpus-online", "%u", header->env.nr_cpus_online); > output_json_key_format(out, true, 2, "nrcpus-avail", "%u", header->env.nr_cpus_avail); > -- > 2.43.0