From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FB32C77B73 for ; Tue, 2 May 2023 09:20:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231808AbjEBJUV (ORCPT ); Tue, 2 May 2023 05:20:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjEBJUV (ORCPT ); Tue, 2 May 2023 05:20:21 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9D4B46B1 for ; Tue, 2 May 2023 02:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=MyDR11ThxB3Qmv3ViyO7alcHP/kjW/srWgW0dtmcR1E=; b=DblbbqqPLl+EO+m9xYXj1MbLNO MRo0P+XVwd1oKciZVpBC6hrRLrKS4KuBR4BXW/EqZEMKeJqa5bMZ9bWRLrH9QmBqsx4f3m+vhOsuv kaYgSw5iOBAEBWKWPYJHt7mVZsv6Bs5HKbB7y+s+n/D+GSa5KVoSw30ItnHNTH8DwsGkvmmaGiWZi 9YAukTztQri0sDcipt1ShVj/D5iCOBGf3MPTdwb7aKC5MPU0PewDJXgwlYkngA+5WzlJw7h+yhpl5 OZXGvcEiK5OAlqKmnx+yPz4mOzZYdrKwmL3yHcSkmmxbWIzAsYFsVIzxC5pAS/FOtwKOf0uhj04ye gDHR+8ng==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ptmB5-008Ak0-Md; Tue, 02 May 2023 09:20:07 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D7AE5300165; Tue, 2 May 2023 11:20:06 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8576823C5C34D; Tue, 2 May 2023 11:20:06 +0200 (CEST) Date: Tue, 2 May 2023 11:20:06 +0200 From: Peter Zijlstra To: Indu Bhagat Cc: linux-toolchains@vger.kernel.org, daandemeyer@meta.com, andrii@kernel.org, rostedt@goodmis.org, kris.van.hees@oracle.com, elena.zannoni@oracle.com, nick.alcock@oracle.com Subject: Re: [POC 3/5] sframe: add new SFrame library Message-ID: <20230502092006.GJ1597476@hirez.programming.kicks-ass.net> References: <20230501200410.3973453-1-indu.bhagat@oracle.com> <20230501200410.3973453-4-indu.bhagat@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230501200410.3973453-4-indu.bhagat@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Mon, May 01, 2023 at 01:04:08PM -0700, Indu Bhagat wrote: > +static unsigned int sframe_get_fre_type(struct sframe_func_desc_entry *fdep) > +{ > + return (fdep) ? SFRAME_V1_FUNC_FRE_TYPE(fdep->func_info) : 0; > +} > + > +static unsigned int sframe_get_fde_type(struct sframe_func_desc_entry *fdep) > +{ > + return (fdep) ? SFRAME_V1_FUNC_FDE_TYPE(fdep->func_info) : 0; > +} vs. > +unsigned int sframe_fre_get_base_reg_id(struct sframe_fre *frep, > + int *errp) > +{ > + if (!frep) > + return sframe_set_errno(errp, SFRAME_ERR_FRE_INVAL); > + > + return SFRAME_V1_FRE_CFA_BASE_REG_ID(frep->fre_info); > +} Inconsistent codying style here... FWIW, I prefer the latter. > +int32_t sframe_fre_get_fp_offset(struct sframe_sec *sfsec, > + struct sframe_fre *frep, int *errp) > +{ > + uint32_t fp_offset_idx = 0; There's an unconditional assignment later, why are you initializing to 0 here? Also, that xmas thing Steve mentioned. > + int8_t fp_offset = sframe_sec_get_fixed_fp_offset(sfsec); > + /* > + * If the FP offset is not being tracked, return the fixed FP offset > + * from the SFrame header. > + */ > + if (fp_offset != SFRAME_CFA_FIXED_FP_INVALID) { > + *errp = 0; > + return fp_offset; > + } > + > + /* > + * In some ABIs, the stack offset to recover RA (using the CFA) from is > + * fixed (like AMD64). In such cases, the stack offset to recover FP > + * will appear at the second index. > + */ > + fp_offset_idx = ((sframe_sec_get_fixed_ra_offset(sfsec) > + != SFRAME_CFA_FIXED_RA_INVALID) > + ? SFRAME_FRE_RA_OFFSET_IDX > + : SFRAME_FRE_FP_OFFSET_IDX); And as such, I'll suggest you write this like: fp_offset_idx = SFRAME_FRE_FP_OFFSET_IDX; if (sframe_sec_get_fixed_ra_offset(sfrec) != SFRAME_CFA_FIXED_RA_INVALID) fp_offset_idx = SFRAME_FRE_RA_OFFSET_IDX; And also, if you'd use shorter identifiers, you'd not constantly run into the line limit like you do. Basically never use ?: unless you _have_ to :-) > + return sframe_get_fre_offset(frep, fp_offset_idx, errp); > +}