Received: by 10.213.65.68 with SMTP id h4csp559303imn; Tue, 13 Mar 2018 13:02:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELt0cZuaSl86Crwp0K9jcOBbBhj+HdTj0zKeT4UCF9Du31V7sJwKaY/u/nEbvqsH+SkxVvBj X-Received: by 10.98.56.131 with SMTP id f125mr1761787pfa.190.1520971374871; Tue, 13 Mar 2018 13:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520971374; cv=none; d=google.com; s=arc-20160816; b=ApUJPsZY72exGYDxfcBhfIXyLLxA541iJVdNKy6hhvq8Xzi8s1McLXpy/BZ0LvDXhr wGuSgil2SCYt92J3FbW5QzBvZO3qN2gnpx4loVyieE7S8CMJopo8yb7h9IsOEHAY5N/t S2CQlCCFpRn41k3ewApXRFg+JQOXeDGPA/YMouYAlRbkGnkc7ZicjKCFpX9YEQWk11w4 xS3p2yT5GleN8Ps9+qktcDqvL+hm6OAMjKaBZjWjJjsV6X484FsZa9kwRDF+zDqWiXud UJetZvdJw1I0hC3eIToEqFpwvO0DNPtjVbiAiULLltRcPdAx0MjlpxEmqvYvm29FqFVS 3QDg== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=mSjPcuPhNea/OyW1AJtODFlM9Xu1KbBROTrWxxWI/bU=; b=hYXej1VDs+QPAkn3UJcBIjCdAOb5v31g716OGDFyBe+GLHN9f4+kSDaIXVPTXiLAWq OWqyFbt1zFY5KxpjPK1mq06EEgE83TM1nPgHnbOXzry8X0OJGsSRw9YEZZc2UnmTan1X VnZca84wkoYdkhZ8MvLpWg5LZCQOYFtQJBLFmpU4G1XxuLXhMYQt3/PhRIAoRQYVCle0 7LooPZQariaoZ4fGb7SSThJjhLUYQiu4q6MJGUYSviOP3LJjJ8Qrup6Ir2CqZLQfU3DG BeAzA69FNqlUZVJoIrPhUWkXhE0tPLVZBkw0Mzb4TdrkWoGSCSWAFh/S/6wTFMA+/0x7 SepA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i07p69TS; 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 b4-v6si655514plk.262.2018.03.13.13.02.40; Tue, 13 Mar 2018 13:02:54 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i07p69TS; 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 S932468AbeCMUB1 (ORCPT + 99 others); Tue, 13 Mar 2018 16:01:27 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:39145 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932257AbeCMUB0 (ORCPT ); Tue, 13 Mar 2018 16:01:26 -0400 Received: by mail-wm0-f66.google.com with SMTP id i3so189971wmi.4; Tue, 13 Mar 2018 13:01:25 -0700 (PDT) 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:in-reply-to:user-agent; bh=mSjPcuPhNea/OyW1AJtODFlM9Xu1KbBROTrWxxWI/bU=; b=i07p69TSSE19TDsqDi7JKQoIMCLBbyKNrnQFkPT74bbtKz+9xhbIfSzctS5mZvQq/5 6YMBHz0iANnXlwxkbLIpS8kM1sgaKCamLwZVyDG4BdhE5jTVf0FYIcdQdF7YH8HgmhO+ ItZOQQX344Ov5nhc9j4ZoON9hEkJMMafDg5kvwIYcPY1572r6G1NH288GWmu4kRXA9La KrE2p7NM6OeClVSfLZtDKmJep9dfEsBHVZjng6dagTj6PW/nkRop1TIhFd8AMq0GNmzZ Nk0vDJlSJfYb4odpFZF15JIYkcVEfqpAi3OKvivqaTYbLfCdw63kaPz0E3EAnJv4Vt9D zB0A== 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:in-reply-to:user-agent; bh=mSjPcuPhNea/OyW1AJtODFlM9Xu1KbBROTrWxxWI/bU=; b=YF5wAyxbJQY0vvYhZO4JsaBSgTQBbQPpzUigkLKJo1SU6qvGBeAnWfxFZNFIHtb5Lm Uv2dHSMJLF+j/ryI8xfS1kYRqyrvEi2QobRaaTSRVdH1fG48Wsze93IeBVlPgsJOAUjV +QpqRmlv5zA8CbStvp0LAzuRV8i+9oQx4d1Q04FqKREo/Guz8UxNsDRS8z0AZuglajcB V0wqsgjLhxXJI92m1S7gluQTb8eWvNpeH/lBgpudTnWuJ7A+tC4dbiKgJ7/gCaDELscQ mhMjB8+kRgXLrWeLAPPD90K91ImB9ja5OuXcmWa6wLZfs5nPF+ONW3PIbjmI84bih7i5 CApw== X-Gm-Message-State: AElRT7GefqqjoNIR84g6Sls3EVBwWQRZ/C04QbReU5UOgTY5rPOAMuW7 vfDsKGIkqcHmdjBFCzohbAE= X-Received: by 10.28.50.69 with SMTP id y66mr1794821wmy.133.1520971284832; Tue, 13 Mar 2018 13:01:24 -0700 (PDT) Received: from ltop.local ([2a02:a03f:41eb:8500:749a:de8c:d62:c682]) by smtp.gmail.com with ESMTPSA id m15sm1053774wrb.58.2018.03.13.13.01.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 13:01:23 -0700 (PDT) Date: Tue, 13 Mar 2018 21:01:21 +0100 From: Luc Van Oostenryck To: Peter Zijlstra Cc: Dmitry Vyukov , linux-sparse@vger.kernel.org, Christopher Li , kbuild test robot , kbuild-all@01.org, LKML , tipbuild@zytor.com, Ingo Molnar Subject: Re: [tip:locking/core 9/11] include/asm-generic/atomic-instrumented.h:288:24: sparse: cast truncates bits from constant value (100 becomes 0) Message-ID: <20180313200119.oydccd4qd5366hfe@ltop.local> References: <201803122219.vHl3IwRo%fengguang.wu@intel.com> <20180313104652.GK4043@hirez.programming.kicks-ass.net> <20180313180016.5axdobx6a624snpp@ltop.local> <20180313180806.GO4043@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180313180806.GO4043@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 07:08:06PM +0100, Peter Zijlstra wrote: > On Tue, Mar 13, 2018 at 07:00:17PM +0100, Luc Van Oostenryck wrote: > > The issue here is that sparse has a whole class of warnings that are > > given very early (here at expansion of constant expressions), before > > eliminating code from branches that are never taken (which, surprise, > > need itself to have constant expressions already expanded). > > > > It's often annoying like the case here. > > OTOH, I don't think it's always a bad thing. Sometimes we want to > > have warnings even from code we know will not be executed (in this > > config but maybe it will in another one). > > Is that really a valid concern with all the automated randconfig > building going on today? I don't think so, for the kernel at least. For other uses it may. But don't take me wrongly: I don't want to defend those warnings here, I just want to say that the situation is not totally black & white. One easy-short-term solution that wouldn't make things ugly would be to use a mask instead of a cast: static __always_inline unsigned long cmpxchg_size(volatile void *ptr, unsigned long old, unsigned long new, int size) { switch (size) { case 1: - return arch_cmpxchg((u8 *)ptr, (u8)old, (u8)new); + return arch_cmpxchg((u8 *)ptr, old & 0xff, new & 0xff); case 2: - return arch_cmpxchg((u16 *)ptr, (u16)old, (u16)new); + return arch_cmpxchg((u16 *)ptr, old & 0xffff, new & 0xffff); -- Luc