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 19134C433EF for ; Tue, 15 Feb 2022 16:55:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237913AbiBOQzX (ORCPT ); Tue, 15 Feb 2022 11:55:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233779AbiBOQzX (ORCPT ); Tue, 15 Feb 2022 11:55:23 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 721BC117C80; Tue, 15 Feb 2022 08:55:12 -0800 (PST) Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id EBADA1EC0535; Tue, 15 Feb 2022 17:55:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1644944107; 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: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=85FEUlBIu7c8gw8c7k99bQj9pHdSOqXZ6/sStTCcMr8=; b=j47rsTlv5hjzO1Nkmit+xbe+OARRqvueOA4vw2ObjxKLl9G3hWsA/V75a64FJWY+h6HeQ0 tRJtp76UF+2FdvW1EZIGUOfhTiN2V/SqBrQH0IJ1+d9djKNnMvpwv2C7fuczr0+n5+p7H2 QGzBCxmUbzJfYm5std+ESynQIDydzFQ= Date: Tue, 15 Feb 2022 17:55:04 +0100 From: Borislav Petkov To: Eliav Farber Cc: mchehab@kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, ronenk@amazon.com, talel@amazon.com, hhhawa@amazon.com, jonnyc@amazon.com, hanochu@amazon.com Subject: Re: [PATCH 3/4] EDAC: Refactor edac_align_ptr() to use u8/u16/u32/u64 data types Message-ID: References: <20220113100622.12783-1-farbere@amazon.com> <20220113100622.12783-4-farbere@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220113100622.12783-4-farbere@amazon.com> Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org On Thu, Jan 13, 2022 at 10:06:21AM +0000, Eliav Farber wrote: > Prefer well defined size variables, that are same in size across all > systems. > > Signed-off-by: Eliav Farber > --- > drivers/edac/edac_mc.c | 17 ++++++----------- > 1 file changed, 6 insertions(+), 11 deletions(-) > > diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c > index 8b9b86a7720a..3367bf997b73 100644 > --- a/drivers/edac/edac_mc.c > +++ b/drivers/edac/edac_mc.c > @@ -250,18 +250,13 @@ void *edac_align_ptr(void **p, unsigned size, int n_elems) > * 'size'. Adjust 'p' so that its alignment is at least as > * stringent as what the compiler would provide for X and return > * the aligned result. > - * Here we assume that the alignment of a "long long" is the most > - * stringent alignment that the compiler will ever provide by default. > - * As far as I know, this is a reasonable assumption. > */ > - if (size > sizeof(long)) > - align = sizeof(long long); > - else if (size > sizeof(int)) > - align = sizeof(long); > - else if (size > sizeof(short)) > - align = sizeof(int); > - else if (size > sizeof(char)) > - align = sizeof(short); > + if (size > sizeof(u32)) > + align = sizeof(u64); > + else if (size > sizeof(u16)) > + align = sizeof(u32); > + else if (size > sizeof(u8)) > + align = sizeof(u16); > else > return ptr; This is just silly. I think you should simply align on 8 and kill all that bla. This whole pointer alignment, then picking out the actual pointers of the embedded struct members is just a bunch of unneeded complexity. I'd like to get rid of it completely one day... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette