Received: by 10.223.164.202 with SMTP id h10csp364795wrb; Wed, 15 Nov 2017 00:43:39 -0800 (PST) X-Google-Smtp-Source: AGs4zMaVZ1dhFQ4CzBWIeqmzWcJGBReUTcRHvUV576beo3iQUyQLpLzXOZo+7elbvRvGm6ICu1XS X-Received: by 10.98.166.148 with SMTP id r20mr16572000pfl.80.1510735419639; Wed, 15 Nov 2017 00:43:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510735419; cv=none; d=google.com; s=arc-20160816; b=LAqE0UOH8kxhvCdimLbJsGHLQKSgAALnPpJwEHciYNtPfl2ulA+tr7N2+VRcVAMEXp zpIkoLyXsDBVsYg60VtsOMHj1UuU+6zVc1ZVJbE+7Df8SyMYMGog4uMMpdRxTTtr/oa9 uKofEpDwjK23astXi7Sm3dEKgq9I3Z4rj4evU//byO20NoDqFgO+yeoETW8Occq/9ipy iZnB9Dx5MHk0fDkeNlZSegjdtPpdnX2cAiILqWilWU6pK2Ibfpl9eWfaaNtl4mg0QUoc +M2PNZ9Mxu70RTJjIAlWc6lLM466Sq3QhLmqL1pI9J8At5eXbCFTzkETzZWRHTd0uWFX wQww== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=nKpg9oeyxvz6wP5g8yYCXSrXb7UbNvvmDOmVLlUKy5M=; b=QpGcgbV+2sfafeqwghdcLG+PLNaTu1XMKUUZY/GO+5tr1ExLcdATeo7uRdpJflmNlD zgkg0+H7M+gyajePipF48kztGtX3cJ+BjSJFMC374HCMrT0kGJAjM4OAohQy5e7j1JnT jLTf1QsmKKgKj/YcIFjd3Op15fuWmGvrrh6v5rukjPrrRIey6hhbTCYG4mdN1nxhzWg6 Mm2StlZ0/JQ06CMCgVvD/YiefsF2euNRDdcoxsToL6r7diNiYS826mms8ivgHuufaEf9 hgMrZkw3gVqA6Zwb99nZO7HVrc74hmW6AnAG3zGLKwfdU+IE9cyNF+2Fru8J6L/a0g83 BjyQ== 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 w88si8986935pfj.200.2017.11.15.00.43.27; Wed, 15 Nov 2017 00:43:39 -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; 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 S1755140AbdKOIgp (ORCPT + 88 others); Wed, 15 Nov 2017 03:36:45 -0500 Received: from mail.santannapisa.it ([193.205.80.98]:22052 "EHLO mail.santannapisa.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751617AbdKOIgh (ORCPT ); Wed, 15 Nov 2017 03:36:37 -0500 Received: from [151.40.112.96] (account l.abeni@santannapisa.it HELO sweethome) by santannapisa.it (CommuniGate Pro SMTP 6.1.11) with ESMTPSA id 125426569; Wed, 15 Nov 2017 09:36:33 +0100 Date: Wed, 15 Nov 2017 09:36:29 +0100 From: luca abeni To: Matthew Wilcox Cc: Peter Zijlstra , Daniel Bristot de Oliveira , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: New sparse warnings from sched.h Message-ID: <20171115093629.79f8ab74@sweethome> In-Reply-To: <20171114204135.GA23685@bombadil.infradead.org> References: <20171114204135.GA23685@bombadil.infradead.org> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, 14 Nov 2017 12:41:35 -0800 Matthew Wilcox wrote: > commit 799ba82de01e7543f6b2042e1a739f3a20255f23 > Author: luca abeni > Date: Thu Sep 7 12:09:31 2017 +0200 > > sched/deadline: Use C bitfields for the state flags > > Ask the compiler to use a single bit for storing true / false > values, instead of wasting the size of a whole int value. > Tested with gcc 5.4.0 on x86_64, and the compiler produces the > expected Assembly (similar to the Assembly code generated when > explicitly accessing the bits with bitmasks, "&" and "|"). > > produces four warnings from sparse for every file which includes > sched.h: > > ./include/linux/sched.h:476:62: error: dubious one-bit signed bitfield > ./include/linux/sched.h:477:62: error: dubious one-bit signed bitfield > ./include/linux/sched.h:478:62: error: dubious one-bit signed bitfield > ./include/linux/sched.h:479:62: error: dubious one-bit signed bitfield > > This seems like the trivial fix (untested): [...] I think Dan Carpenter sent a similar patch (and I replied agreeing with it). I believe in this particular case signed integers are safe, but if "unsigned int" is the preferred style in the kernel I agree with the change. Thanks, Luca > > > diff --git a/include/linux/sched.h b/include/linux/sched.h > index a5dc7c98b0a2..21991d668d35 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -473,10 +473,10 @@ struct sched_dl_entity { > * conditions between the inactive timer handler and the > wakeup > * code. > */ > - int dl_throttled : 1; > - int dl_boosted : 1; > - int dl_yielded : 1; > - int dl_non_contending : 1; > + unsigned int dl_throttled : 1; > + unsigned int dl_boosted : 1; > + unsigned int dl_yielded : 1; > + unsigned int dl_non_contending : 1; > > /* > * Bandwidth enforcement timer. Each -deadline task has its From 1584075628374159346@xxx Tue Nov 14 20:44:02 +0000 2017 X-GM-THRID: 1584075628374159346 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread