Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp343928rwb; Fri, 18 Nov 2022 02:11:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf6IayV0Wy+PorVN6Q7s30OxyScYnY+83+G7kpRvreS9aGMQq+puf847fObXEXKBbRDXdoLg X-Received: by 2002:a17:90b:35cc:b0:213:e907:5c0d with SMTP id nb12-20020a17090b35cc00b00213e9075c0dmr6794691pjb.83.1668766309929; Fri, 18 Nov 2022 02:11:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668766309; cv=none; d=google.com; s=arc-20160816; b=LiJQZyUN4E9+uiZFzSoFOw1sIdSQb4XYjHNAnrqiGL8oTpYoUyWHYFLp808zISPY+E imgBUHp4RLdL1FVbtuldPhlG9Kp8hId8CJwV+aXNn5ec4UM4xZbwldBXKV35M7wsEVQ0 Y8O2oIryIhm05WKGh4b3m148rX2+UYbuahK+3ji2hJFlNc4/XxZW0ofQk1y0KWlZktC1 bfuLMjaXe2MFJfaURlfWNcjJmzbOMH4As25/zsVORls2AdRE5O/3jEYoQ/YLTGHQ6a/K Va+iO7i4fLNj3hYq3vYwj4rVlIe/paPJ1xOoqHf42ofPxanVnj0/2JUt3QoVA8PEQ84L 6VGw== 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=K6hK8A2rAN4d24KDK5ABoo0V031IyWeiGrh9El3YUPY=; b=ftmINr3FXRjiiRE2CZJ3RLJ7+rAwt6pjzhKCKQeTFrmIR5uyw6V2lAYhjuoAymd3nC XHaLbLm6fKz3X7gA3l2i/uaDY9wXK7kkwg29P4fnKlAOlndpLIdAcMX8t2Bb1fNo8/hq JT3pkDr0AxrLO51ydaWjjrzYQj/P7cxlSC9fg1grm83qbLEGteL369uQPH0rQtM59/tZ NG68BaI8OwQ58Y//HmXYXr750kGo6zWqxXAGMoJsbUsFUE1CRNirlezPnd47Q59cCVjh TNngy69+eyMIY99LO6TGP7qxEArEhiepb5sdOLVL2Wd9Sh0QQ6fDBUZhvWFKfrzJDQ7c 8aHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WMSkKPKV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170903018900b00184c33ddeb8si3760818plg.23.2022.11.18.02.11.38; Fri, 18 Nov 2022 02:11:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WMSkKPKV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241437AbiKRJBn (ORCPT + 90 others); Fri, 18 Nov 2022 04:01:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235167AbiKRJBj (ORCPT ); Fri, 18 Nov 2022 04:01:39 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2024D697DD for ; Fri, 18 Nov 2022 01:01:39 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso7040978wme.5 for ; Fri, 18 Nov 2022 01:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=K6hK8A2rAN4d24KDK5ABoo0V031IyWeiGrh9El3YUPY=; b=WMSkKPKVgzPshxJZXoPqCgykFa2Q6jLIDq9gctLfPDbYW+zXN5wTHSIOyT1Eqpzyqy /Oa6/hyYWTWoxAgyQ5e54+GfGzjsC6e7lzw0KFQUOy/KhcOef3ixOCdXPvzhKZ1lnY4v URbbGTQ+S5yFATOWflB8AcCgi1tBqLVboO42SF/ZJ31z45/vWC4Ul3tJnKZ2HayJSeVT +/s4y5x8cNP10J5PiZhhqsDB5LGh/BXwIECwjIm34lqTwr7Lk6d0J3Fu1ouImD0g8LKJ 3Phczu2ipekrMIa8aVYmFGgO1bN2tCRJ/3YTw2xZwUWvwS4L/DAJkXWcKeTON9p6dRyh d1HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=K6hK8A2rAN4d24KDK5ABoo0V031IyWeiGrh9El3YUPY=; b=7EP+NsrM+UndS8WwAk9ltwV0k2S9Pr9vF4tkTRPzZqUEAabHbPhUi17pMoGWOp7Mx4 LJeTAAOx+N1KrmdSfFZ7+Y2H5da3aa57ObD57O5dkLPAkr3ApURS49DapSAmD4n/IB5D u+zvuYzdJx7U6YniSaQT6HYqrW90rCLiXX8t7a2/ADl+7ApXg+kg83xy3OdPIe5dOVM1 UDRdsog1WdiZ7foZYYy25YV0S+A4BM9XeYVV9VrlQbGw+OH35NqSy3qLgh1SlV/8tP71 FY6ko1yBxe+IpFkbbprUIHFFi1aPl1WOfGTUJr7LodQ/yNRYvlSgHqNoXxSmp0niUwTT IR7g== X-Gm-Message-State: ANoB5pm9iMnbZEsLhwYSdKvlokcLKaTGrs646LxoiacefrXVcwu4gtEf TrZcRPwL+Z3sf0VdF2EpCJw= X-Received: by 2002:a05:600c:35cf:b0:3cf:aa11:93a8 with SMTP id r15-20020a05600c35cf00b003cfaa1193a8mr7851714wmq.31.1668762097604; Fri, 18 Nov 2022 01:01:37 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id 23-20020a05600c229700b003cf75213bb9sm7980034wmf.8.2022.11.18.01.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:01:37 -0800 (PST) Date: Fri, 18 Nov 2022 12:01:34 +0300 From: Dan Carpenter To: Andrew Lunn Cc: Umang Jain , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Greg Kroah-Hartman , Hans Verkuil , Dave Stevenson , Mauro Carvalho Chehab , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, kieran.bingham@ideasonboard.com Subject: Re: [PATCH 2/3] vc04_services: mmal-vchiq: Use bool for vchiq_mmal_component.in_use Message-ID: References: <20221117160015.344528-1-umang.jain@ideasonboard.com> <20221117160015.344528-3-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 18, 2022 at 01:23:36AM +0100, Andrew Lunn wrote: > > struct vchiq_mmal_component { > > - u32 in_use:1; > > + bool in_use:1; > > bool enabled:1; > > The patch you referenced says: > > +If a structure has many true/false values, consider consolidating them into a > +bitfield with 1 bit members, or using an appropriate fixed width type, such as > +u8. > > The code did exactly this, using two bits fields, in one u32. A bool > probably takes up 4 bytes, maybe 8 bytes, so this change probably > doubles the storage size for these two fields. In GCC and Clang bools take a byte, but the C language is vague and other compilers are free to do it differently. > Are these fields on the > hot path, where an extra AND instruction would make a difference? This patch takes the first u32 for "in_use" and squeezes it into the same byte as "enabled" so it makes the struct four bytes smaller. There is still a 3 byte struct hole between "enabled" and "handle" so we could add more 62 bool bitfields if we wanted. In the v2 patch these become: bool in_use; bool enabled; One byte each and there is a two byte gap before "handle". regards, dan carpenter