Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1975731ybz; Thu, 23 Apr 2020 09:21:48 -0700 (PDT) X-Google-Smtp-Source: APiQypIhGZ3vw2wlVH+CpEhdVLcipxnwBESah+k7J6xHQo2xq9459A8+3EO7jtD3m97zb75W/TcY X-Received: by 2002:a17:906:7c4e:: with SMTP id g14mr3397677ejp.382.1587658908100; Thu, 23 Apr 2020 09:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587658908; cv=none; d=google.com; s=arc-20160816; b=wIedCFqnWftLlqG+TLMy0RQvtWAngH1bVDI++5ZskrWy+c9G5iZ+ZwuVTQJp+FpDI2 NmDr631O/POHDw1uzpHTJvHJtXf3HsotCQVv5ZY33+28vsWxBWBaAhGxaRj8SWCvuFcE Z/uL41asDR5JpaYeeyDSOh0nWyapFe7YmG+mLidwbBeZ3J2+B1qogTDnmI5tBmjFXh8c 6Z6V345nRwcABa925R8xx82Rl/ND1DpFQjlZA5JUG8iLvstPpVrsGrvxF3hTETFKH+zJ 9C+BGyQhfPpUaUFPL/6gYOmVb8XX9ByY4BhRYNEr+rNn88BnTPnkAZj8ToDBZ/2x61CC +QHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iZrweN9eLmW7wiF8Ronk6pSDprkhVTVjX9L9M75OoZs=; b=ouSOpPF+3k2c9tMaxn9D7z/I/W/X5Mc1du/KRjPNfhkWJbtkVMWVc/UbcmvFi24MB6 qP86fjBu9EXpm6IoJ2DVPrh0TTU1UyA9gujk18JQu1TGjJ8kbmLLWVHEllbVDnqtNDZV /QpLC/8C8PWtpSXM7C4xGPr54pzoiWJyGOfwDEy+pUNHky8e2svlT14GF4Zm+m7n6CP4 V2dGpryx5yEQri7nhCbRLJtpsJmzA90HjO2S74sQQ9bOKO7+NW+AXqxP2Kd03uI1E5/J 3Ovra+MAT0Z++qa+iz3cwgEewkEisxck61AF+rHicgHluyAweYyDPzpK3QUScz6QDAVv 49jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=neRdBchb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qt4si1405496ejb.447.2020.04.23.09.21.23; Thu, 23 Apr 2020 09:21:48 -0700 (PDT) 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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=neRdBchb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729561AbgDWQRZ (ORCPT + 99 others); Thu, 23 Apr 2020 12:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728865AbgDWQRY (ORCPT ); Thu, 23 Apr 2020 12:17:24 -0400 Received: from merlin.infradead.org (unknown [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BAFAC09B041 for ; Thu, 23 Apr 2020 09:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=iZrweN9eLmW7wiF8Ronk6pSDprkhVTVjX9L9M75OoZs=; b=neRdBchbbP/OCKWE1H8nvjo05d G9JLZSe9YX/XQFqNTHIfrP7XR9DJO9ShBHV48JuK7NFFjaMBDu/Mq40T8bwbTTXk1uwj9ArtGRYeL zE0ADuBVmC+Z97jnuGwENDR3tzuNumnyHi9sKZ2aAsd0ONUhuelR/UJbC+Dcu0ONtHnV3zAah86aw 7n4ILg4oSvGYQ0IPHMcN7wZy4fn5yaR4a2BlsjHeAIvx83dvLqTxnGHRlh+VwKf5v/rxv7aVn6Qw2 LlcEsHxqV1pjvCGvMLRLpbNYbml+HNF3jc+62jfh+IgoQNUW9UAwAx+vcVMNv3p9UYtBFP0u0H5dV /eAS69hw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jReX5-0003Fv-9x; Thu, 23 Apr 2020 16:16:59 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 29B583011C6; Thu, 23 Apr 2020 18:16:56 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 16EBC2392DE85; Thu, 23 Apr 2020 18:16:56 +0200 (CEST) Date: Thu, 23 Apr 2020 18:16:56 +0200 From: Peter Zijlstra To: Alexandre Chartre Cc: jpoimboe@redhat.com, linux-kernel@vger.kernel.org, jthierry@redhat.com, tglx@linutronix.de, x86@kernel.org, mbenes@suse.cz Subject: Re: [PATCH 3/8] objtool: Rework allocating stack_ops on decode Message-ID: <20200423161656.GX20730@hirez.programming.kicks-ass.net> References: <20200423125013.452964352@infradead.org> <20200423125042.713052240@infradead.org> <7df9ec97-dc14-c4b6-fb26-f163e9afb1cd@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7df9ec97-dc14-c4b6-fb26-f163e9afb1cd@oracle.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 23, 2020 at 05:40:38PM +0200, Alexandre Chartre wrote: > > On 4/23/20 2:47 PM, Peter Zijlstra wrote: > > Wrap each stack_op in a macro that allocates and adds it to the list. > > This simplifies trying to figure out what to do with the pre-allocated > > stack_op at the end. > > > > Signed-off-by: Peter Zijlstra (Intel) > > --- > > tools/objtool/arch/x86/decode.c | 257 +++++++++++++++++++++++----------------- > > 1 file changed, 153 insertions(+), 104 deletions(-) > > > > --- a/tools/objtool/arch/x86/decode.c > > +++ b/tools/objtool/arch/x86/decode.c > > @@ -77,6 +77,17 @@ unsigned long arch_jump_destination(stru > > return insn->offset + insn->len + insn->immediate; > > } > > +#define PUSH_OP(op) \ > > +({ \ > > + list_add_tail(&op->list, ops_list); \ > > + NULL; \ > > +}) > > + > > +#define ADD_OP(op) \ > > + if (!(op = calloc(1, sizeof(*op)))) \ > > + return -1; \ > > + else for (; op; op = PUSH_OP(op)) > > + > > I would better have a function to alloc+add op instead of weird macros, > for example: I know it'll not make you feel (much) better, but we can write it shorter: +#define ADD_OP(op) \ + if (!(op = calloc(1, sizeof(*op)))) \ + return -1; \ + else for (list_add_tail(&op->list, ops_list); op; op = NULL) Also, the kernel is full of funny macros like this ;-)