Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp187192pxb; Wed, 18 Nov 2020 01:39:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOs3CKQhzgqWD7KLUJAdniLNqNJVzMHqXz2li0887ec4WdCTJqFvstqzvy8WL29NsgmFHj X-Received: by 2002:a17:906:cd0f:: with SMTP id oz15mr23567425ejb.200.1605692353322; Wed, 18 Nov 2020 01:39:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605692353; cv=none; d=google.com; s=arc-20160816; b=Bu6Nb+zuyGVaue9gBcCmwqs2L8sQcB7IfAPCBPMox6dNyXhu15Z2BbkAVTJchE0oMz /oIpUFR2PYTY8Jl4nCLMUEyv/wcvP6wy1jFmrRnGhDBItn2cIF7pU64jpv9mE2Fd9vkt QmWo20nLeAdrOYz5NTNLv+Y0a2CwbrJiuefncNDZK6+46v19s4FoRJXCr9VSQ0KRO1iM Q39cDyJNEmonodDejVgkwI6FLyBb3Q9pmKnq/aMBVGhG//t48DAAiIRfWic7XWPXVcSM 5BsFSXtG8BNr/87ZYkVVfjTfQLFTgyQVXbo5YQlEcV7YbE/fYVrKqRrRm85W0/6DDhBy t9Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=u7oDgWHxu4+MRhAydEZNRlN5kWaVQTY+ZlvNsq17iNM=; b=t8d+A6WKUUsFq9zHCiuUcowU9ys2LZ1q0mA+ADbmV2wL6RMU1HMMi816xAZJ9OWB5/ pF2fSMX9BFRqwfB5ek9abRJhvX5j8wp1o5j8vdaVikycMdW8vK/PUurgpV9CScv0TxmQ gOSB6GX00RGt+JDPPXOKDaOog4NHwx4g4IWwweFTZy5heAEq17j68YUpQU0hUNeU2xPU pSwdnkFQ8d6ROMh/EgbGFEZ9/CHO1r+YzK6fGYX9Fz6HHik+BUXTmNz9Z7Y0Xe+qLGXb ibO2hASbVj0FOJbb6hswc28gNWGHIzd5D7EI7WAIHXGp5pXZbRKI4Sed6jWb++eRe+2k cIEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CH9CFwjo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h25si14416633ejt.198.2020.11.18.01.38.50; Wed, 18 Nov 2020 01:39:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CH9CFwjo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725964AbgKRJf7 (ORCPT + 99 others); Wed, 18 Nov 2020 04:35:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34418 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725772AbgKRJf6 (ORCPT ); Wed, 18 Nov 2020 04:35:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605692157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=u7oDgWHxu4+MRhAydEZNRlN5kWaVQTY+ZlvNsq17iNM=; b=CH9CFwjoKL4eo+aKdWmS4Q0g5+3K+oL+71T1k8SkoczkJPUE0tdZIXB54MC3YavFCBrjHc QYyX2SF/JsVmRnOLEUk1PRurWP2a2UhxFhH8V0iMMeYoc3cV3qZma3058Ztz4URtj9igUC l4XtpB6KpdrAIBM/EDnGPyOagCzfJzc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-uJbNMfRqM3SELhkJ-tBYXw-1; Wed, 18 Nov 2020 04:35:53 -0500 X-MC-Unique: uJbNMfRqM3SELhkJ-tBYXw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F31CB1028D41; Wed, 18 Nov 2020 09:35:50 +0000 (UTC) Received: from krava (unknown [10.40.193.155]) by smtp.corp.redhat.com (Postfix) with SMTP id 3DECF6B8E5; Wed, 18 Nov 2020 09:35:46 +0000 (UTC) Date: Wed, 18 Nov 2020 10:35:45 +0100 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Jiri Olsa , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: Re: [PATCH 06/24] perf tools: Add build_id__is_defined function Message-ID: <20201118093545.GB1414446@krava> References: <20201117110053.1303113-1-jolsa@kernel.org> <20201117110053.1303113-7-jolsa@kernel.org> <20201117205359.GJ1216482@krava> <20201117233313.GD657351@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117233313.GD657351@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 08:33:13PM -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Nov 17, 2020 at 09:53:59PM +0100, Jiri Olsa escreveu: > > On Tue, Nov 17, 2020 at 11:00:37AM -0800, Ian Rogers wrote: > > > On Tue, Nov 17, 2020 at 3:01 AM Jiri Olsa wrote: > > > > > > > Adding build_id__is_defined helper to check build id > > > > is defined and is != zero build id. > > > > > > > > Signed-off-by: Jiri Olsa > > > > --- > > > > tools/perf/util/build-id.c | 7 +++++++ > > > > tools/perf/util/build-id.h | 1 + > > > > 2 files changed, 8 insertions(+) > > > > > > > > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c > > > > index 6b410c3d52dc..7d9ecc37849c 100644 > > > > --- a/tools/perf/util/build-id.c > > > > +++ b/tools/perf/util/build-id.c > > > > @@ -912,3 +912,10 @@ void build_id__init(struct build_id *bid, const u8 > > > > *data, size_t size) > > > > memcpy(bid->data, data, size); > > > > bid->size = size; > > > > } > > > > + > > > > +bool build_id__is_defined(const struct build_id *bid) > > > > +{ > > > > + static u8 zero[BUILD_ID_SIZE]; > > > > + > > > > + return bid && bid->size ? memcmp(bid->data, &zero, bid->size) : > > > > false; > > > > Fwiw, I find this method to test for zero a little hard to parse - I'm > > > > heh, it's controversial one, Namhyung commented > > on this one in previous version, so I changed it ;-) > > https://lore.kernel.org/lkml/CAM9d7cjjGjTN8sDgLZ1PoQZ-sUXWjnVaNdyOVE1yHxq46PrPkw@mail.gmail.com/ > > So, the kernel has an idiom for this in lib/string.c: > > /** > * memchr_inv - Find an unmatching character in an area of memory. > * @start: The memory area > * @c: Find a character other than c > * @bytes: The size of the area. > * > * returns the address of the first character other than @c, or %NULL > * if the whole buffer contains just @c. > */ > void *memchr_inv(const void *start, int c, size_t bytes) > > No need for any array of some particular size :-) ok, will check thanks, jirka