Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3918877imu; Mon, 7 Jan 2019 11:55:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN6W63AsfbSCQhVb7viniL5k41N8L0M8Mk3oCpP+lyPVV0KjA/YCWgylah/ha7BGqkmZLqn/ X-Received: by 2002:a17:902:365:: with SMTP id 92mr59851173pld.327.1546890956279; Mon, 07 Jan 2019 11:55:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546890956; cv=none; d=google.com; s=arc-20160816; b=VGyEiuSmg/rveETaBZNltSsPwW2mkew8z8fzPtCa7O+ezRXYVN9BUreB+fnGAO/ejV nQcUtzNx7TPQ4TNfLmMkMQ30paGHYlnNWAVVWKd6o5VPUAOxsgufzHWAL+9cvI2npjkR SXstUf8y7o9ytROVspJa40OIrSkUyoGFhG3G+h1lmCHn2Rh0c2MTmNpi0sfWoUf9lGN4 HhrK8blQnkB4aEHVQ6q81TfyEnXv3Y9z7BVG48P8JPmyRAg42Lq5V72OLoJkTvRRDDL9 Rw6CTrMs6IDheknAmn5xnsHY4hoDy7AWfOR/DguY1kvOM2lxqsbvpDJ5cH7bKA/n1vyG z04Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LyK0RGSnDLBKcnzEtoopjbp/ZcAzp0tD5nabM9I/cFg=; b=y4aT21InBCggQDGhMQLJNeIqLhmBfTgS9JCHWhg/a0OEdSl36YNhTGPO24M/+Rwznt Yzw5F1BcGo786MJccNKYZ2enzHJyZFLdc1Tl57s7k9N4BVAbw0cS5ow6iSXIopg5zKP+ hcmt+KS16G8mOMEwuZhwnccUX46AwSlisuH3U3yhMA66PunqCDAdAaegm9mYUsPdbbL6 hlg8xFXWVzt8KhRWpGsxuOr6KWwWX/XZ4hnAjtAtIU1UKuYBE45V3ICSogDdbpaIr5q4 em0joUmnYaGerQ952vAt+puKfnAmyDlMOWi9/15GD19DnXvu+C5RkccQ6g+Zel+M2Ixb lHOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a33XiXj+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 93si39731138plc.2.2019.01.07.11.55.41; Mon, 07 Jan 2019 11:55:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a33XiXj+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727700AbfAGR56 (ORCPT + 99 others); Mon, 7 Jan 2019 12:57:58 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44543 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbfAGR56 (ORCPT ); Mon, 7 Jan 2019 12:57:58 -0500 Received: by mail-pl1-f195.google.com with SMTP id e11so482809plt.11; Mon, 07 Jan 2019 09:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=LyK0RGSnDLBKcnzEtoopjbp/ZcAzp0tD5nabM9I/cFg=; b=a33XiXj++aofqToiVtFvZNO/wxrOjwILKPk5WSNYkVMikCV7CWl/JcdUnRbQd2hb5E xaM3Fy9AJ7G4VrqezIGr3sKLxZyvWkAm5vKlN1ULrHSUQWvfXwhmYqLHVXCp6ivG4nGI QDrTV7qZlsewO0slAnxJtqkZ3z8GvPDSbjrTHZvAmwbxTmL9ThI0dixkAZR9SnXuWu0f f9cLnu3te0Axap70oCh90VgIuabeA6i+BOy+x7qkPbYQVW7xvNo3pwUVfMR11IK6fFV0 bTWXcdIoCsVmdRhkqcFTWYHs//v/mVmRaybwI07uLO+a8E1bb/3IAhLyQvgD0l0sxGaN aHwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=LyK0RGSnDLBKcnzEtoopjbp/ZcAzp0tD5nabM9I/cFg=; b=NVK/xmKGgPEhz3snl20iNk8j6OcB2Wa03Yef82V6WdcbEdBBsDDplizfJgUFiYjdoc fiX07e4rLErCotrCRPXzawLOXFnF6E1LddQTIQRV8ts3ypyIUhvy63hsk6ejhQ+QyfjT g9hOAi1yP4SM/z6NNah3My0cEEPKB2p2KMKw++UF5H3uV7BMPbGpSXchYAoso7F8ncWH 5HcG+8fzOd5Z7vIYrSVC54IxS7JBdWobuhj94V2xxSBNZNe31tfUjQ+ByGq9z9kLsayx m5uN38kWiovmmv2gr2KHgMRtx3rg//wXBV5JsJ1DfCy3FBRra7f+etJwVgkI42iM1qyN feZg== X-Gm-Message-State: AJcUukdUo//jOuYl+saBRBVJWPKIIpDucqTEqdgZ+LYaU7dlYct9BANV MGGHa/wTqUnPkXMhLfHNsNw= X-Received: by 2002:a17:902:7848:: with SMTP id e8mr63434845pln.100.1546883877196; Mon, 07 Jan 2019 09:57:57 -0800 (PST) Received: from himanshu-Vostro-3559 ([103.233.116.134]) by smtp.gmail.com with ESMTPSA id i184sm93904921pfc.41.2019.01.07.09.57.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 09:57:56 -0800 (PST) Date: Mon, 7 Jan 2019 23:27:48 +0530 From: Himanshu Jha To: Matt Ranostay Cc: Amir Mahdi Ghorbanian , lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Staging: iio: ad7192: replaced bool in struct Message-ID: <20190107175748.GA29220@himanshu-Vostro-3559> References: <1545434786-15220-1-git-send-email-indigoomega021@gmail.com> <20181224095823.GA17061@himanshu-Vostro-3559> <8E720BF2-7AFC-4FFA-8FA2-5A403FD5DD1D@konsulko.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8E720BF2-7AFC-4FFA-8FA2-5A403FD5DD1D@konsulko.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 02, 2019 at 01:25:27PM -0800, Matt Ranostay wrote: > > > On Dec 24, 2018, at 01:58, Himanshu Jha wrote: > > > >> On Fri, Dec 21, 2018 at 03:26:26PM -0800, Amir Mahdi Ghorbanian wrote: > >> Replaced bool in struct with unsigned int bitfield to conserve space and > >> more clearly define size of varibales > > Important thing to note is depending on padding, alignment, and position of field it probably won’t save any space. Well, then what do you say about the following results ;-) Before: ------ himanshu@himanshu-Vostro-3559:~/gsoc/linux$ pahole -C ad7192_platform_data drivers/staging/iio/adc/ad7192.o struct ad7192_platform_data { u16 vref_mv; /* 0 2 */ u8 clock_source_sel; /* 2 1 */ /* XXX 1 byte hole, try to pack */ u32 ext_clk_hz; /* 4 4 */ bool refin2_en; /* 8 1 */ bool rej60_en; /* 9 1 */ bool sinc3_en; /* 10 1 */ bool chop_en; /* 11 1 */ bool buf_en; /* 12 1 */ bool unipolar_en; /* 13 1 */ bool burnout_curr_en; /* 14 1 */ /* size: 16, cachelines: 1, members: 10 */ /* sum members: 14, holes: 1, sum holes: 1 */ /* padding: 1 */ /* last cacheline: 16 bytes */ }; After: ----- himanshu@himanshu-Vostro-3559:~/gsoc/linux$ pahole -C ad7192_platform_data drivers/staging/iio/adc/ad7192.o struct ad7192_platform_data { u16 vref_mv; /* 0 2 */ u8 clock_source_sel; /* 2 1 */ /* XXX 1 byte hole, try to pack */ u32 ext_clk_hz; /* 4 4 */ unsigned int refin2_en:1; /* 8:31 4 */ unsigned int rej60_en:1; /* 8:30 4 */ unsigned int sinc3_en:1; /* 8:29 4 */ unsigned int chop_en:1; /* 8:28 4 */ unsigned int buf_en:1; /* 8:27 4 */ unsigned int unipolar_en:1; /* 8:26 4 */ unsigned int burnout_curr_en:1; /* 8:25 4 */ /* size: 12, cachelines: 1, members: 10 */ /* sum members: 11, holes: 1, sum holes: 1 */ /* bit_padding: 25 bits */ /* last cacheline: 12 bytes */ }; > Also for internal unpacked structures it really makes little sense to save a few bytes of data. Don’t read into that packed structures are good.. they usually aren’t :) Yes, agreed, but I often see patches to save few bytes by marking array as static. There is some effort in this direction: https://lore.kernel.org/lkml/20181221235230.GC13168@ziepe.ca/ Very likely to get more patches if the above patch gets merged. -- Himanshu Jha Undergraduate Student Department of Electronics & Communication Guru Tegh Bahadur Institute of Technology