Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1684940imd; Sat, 27 Oct 2018 15:01:00 -0700 (PDT) X-Google-Smtp-Source: AJdET5fpPhJbv8Q2ByetD6ckLguVpBekPRSjg0mx3C20REDFpZX9ehIBQ888D2aaq0PB5cy2hC3Q X-Received: by 2002:a62:104b:: with SMTP id y72-v6mr9106396pfi.113.1540677660364; Sat, 27 Oct 2018 15:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540677660; cv=none; d=google.com; s=arc-20160816; b=r0IBmtsGqLvmxy/ruogjMT7dO3aqBvCr9CKJIeg4kjZXLIrOz8JbGbB6cDFE3S9WBf pHer6TGbkH4jQuKDlPi+FddkghiQVYAClMaNaOGI0KdA1Cz+V8mVLm+VCuqYdPuCELLK 6vEmc+SOQ9zVBdi4O7v3hHLeWjV7S8e52ok+J9qB0VbKgxcB4CyGBz4nxof/DfEKHkKW pWa3wg915EMeLr61xC/B6g57sLNl5zYio7cCNBt6+8Y/I9EKc7kn+ByMN1JV+OqHCizu GjPlV+cIp2xcDxT7yUhgEzbmHBFA+yftNTCV0fQFR55sDN+gmLIkphz2X7ka4wXfyUAR r/xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=GE/nP5OJT5YZceJBUI+JvU2G+4f9EyUpai3d5wpSzKA=; b=sVZRNjEaGvZIkKHJ3uBcbgmj94/G5Vu1VGyuGuVJk73kfo5plrG37GUk9l7Dl+uY+a ptdZJw/4RrGh2MJZtZPeC0dINIsjZEMTQ7v6cX1wjSmFfTVpyI65jYqFXSHkJtaV25+/ dUTCJuQ4QzDp85E3hQDRPRDvznLgFvvfCKDmXZzx/aZ1ERmQj/QpyVqTHUC0XfnT+u7b t5juNOS7FWckZlys4bbghnFf6Kis6ivOkD/b6Bihw5FrtOfLoaUTe1NPW3fGG7m5RXDy mR+W6594gAMDDuIH0DEdB4dwOzPFY1JAeKAqH7hqB2i1tRipRnXsAJl3C8Djzp1ca45j xX9A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15-v6si15373220pgg.477.2018.10.27.15.00.29; Sat, 27 Oct 2018 15:01:00 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbeJ1Gl6 (ORCPT + 99 others); Sun, 28 Oct 2018 02:41:58 -0400 Received: from smtprelay0079.hostedemail.com ([216.40.44.79]:46370 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726625AbeJ1Gl6 (ORCPT ); Sun, 28 Oct 2018 02:41:58 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id E11A1837F24D; Sat, 27 Oct 2018 21:59:34 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:599:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2196:2197:2199:2200:2393:2553:2559:2562:2693:2828:2901:3138:3139:3140:3141:3142:3355:3622:3653:3743:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4385:4605:5007:7514:7903:10004:10400:10848:11026:11232:11658:11914:12043:12296:12555:12740:12760:12895:12986:13255:13439:13869:14096:14097:14181:14659:14721:14819:21080:21221:21433:21451:21627:21740:21773:30005:30012:30054:30070:30090:30091,0,RBL:47.151.153.53:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: money65_536bbe3c9132a X-Filterd-Recvd-Size: 4043 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf10.hostedemail.com (Postfix) with ESMTPA; Sat, 27 Oct 2018 21:59:33 +0000 (UTC) Message-ID: <5ac9cc7060a4a942a7c362cfe35515bd3c7820fb.camel@perches.com> Subject: Re: [Outreachy kernel] [RESEND PATCH 2/2] staging: vboxvideo: Use unsigned int instead bool From: Joe Perches To: Julia Lawall , Sasha Levin Cc: Shayenne da Luz Moura , Greg Kroah-Hartman , Hans de Goede , Michael Thayer , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com Date: Sat, 27 Oct 2018 14:59:32 -0700 In-Reply-To: References: <211701e4ae42acd95afb24713314bce5a4c58ecf.1540580493.git.shayenneluzmoura@gmail.com> <20181026204225.GH2015@sasha-vm> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2018-10-26 at 22:54 +0200, Julia Lawall wrote: > [Adding Joe Perches] > > On Fri, 26 Oct 2018, Sasha Levin wrote: > > > On Fri, Oct 26, 2018 at 04:04:45PM -0300, Shayenne da Luz Moura wrote: > > > This change was suggested by checkpath.pl. Use unsigned int with bitfield > > > allocate only one bit to the boolean variable. > > > > > > CHECK: Avoid using bool structure members because of possible alignment > > > issues > > > > > > Signed-off-by: Shayenne da Luz Moura > > > --- > > > drivers/staging/vboxvideo/vbox_drv.h | 14 +++++++------- > > > drivers/staging/vboxvideo/vboxvideo_guest.h | 2 +- > > > 2 files changed, 8 insertions(+), 8 deletions(-) > > > > > > diff --git a/drivers/staging/vboxvideo/vbox_drv.h > > > b/drivers/staging/vboxvideo/vbox_drv.h > > > index 594f84272957..7d3e329a6b1c 100644 > > > --- a/drivers/staging/vboxvideo/vbox_drv.h > > > +++ b/drivers/staging/vboxvideo/vbox_drv.h > > > @@ -81,7 +81,7 @@ struct vbox_private { > > > u8 __iomem *vbva_buffers; > > > struct gen_pool *guest_pool; > > > struct vbva_buf_ctx *vbva_info; > > > - bool any_pitch; > > > + unsigned int any_pitch:1; > > > u32 num_crtcs; > > > /** Amount of available VRAM, including space used for buffers. */ > > > u32 full_vram_size; > > > > Using bitfields for booleans in these cases is less efficient than just > > using "regular" booleans for two reasons: > > > > 1. It will use the same amount of space. Due to alignment requirements, > > the compiler can't squeeze in anything into the 7 bits that are now > > "free". Each member, unless it's another bitfield, must start at a whole > > byte. > > > > 2. This is actually less efficient (slower) for the compiler to work > > with. The smallest granularity we have to access memory is 1 byte; we > > can't set individual bits directly in memory. For the original code, the > > assembly for 'vbox_private.any_pitch = true' would look something like > > this: > > > > movl $0x1,-0x10(%rsp) > > > > As you can see, the compiler can directly write into the variable. > > However, when we switch to using bitfields, the compiler must preserve > > the original value of the other 7 bits, so it must first read them from > > memory, manipulate the value and write it back. The assembly would > > look something like this: > > > > movzbl -0x10(%rsp),%eax > > or $0x1,%eax > > mov %al,-0x10(%rsp) > > > > Which is less efficient than what was previously happening. > > Maybe checkpatch could be more precise about what kind of bools should be > changed? Probably so, what verbiage would you suggest? Also, any conversion from bool to int would have to take care than any assigment uses !! where appropriate.