Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7261501imu; Wed, 14 Nov 2018 14:26:22 -0800 (PST) X-Google-Smtp-Source: AJdET5eTfmWOEaMd8uh0o5tVPvJSa6qZVeBYpGLGmoi4C2YWuZQEEIDc1Tx1joV7R3EiGsXy7R4H X-Received: by 2002:a62:3c6:: with SMTP id 189-v6mr3777091pfd.19.1542234382550; Wed, 14 Nov 2018 14:26:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542234382; cv=none; d=google.com; s=arc-20160816; b=j7/gw5HsjfwHSIdJTr7/mbTGgInGDuxrbtES5ZgePO+yn60YyaVng8vxvwoZPnmfDd w0BkfdWBc1OmGsEFZO5+79eSfbuxsRrMMtQo4S3D0Z8JN1GlG8NSkkMLOcsKBZFJAjIv jYuXrwXfJbdkwuMHQOeLbY1zl6+TSOq5o8KKwmJndtN9t1HVuotyIAsbYmbLaxCICELr 2EjKHTkRxonziVxz5OE1aBr4EKBRrzddFyskpLfXeaxiuZuI5NhjIK/VFeFLnYUviqL8 BaKOX5c5cyZL+g/5wD8whCxafDOKB4Sb3mQZqM+MaYh1u3JgNzRPStWtgllfnCBCp+9m hscw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=L4pSjUmIOTE0zfl+uSAhUu8uxkMsgvMqkVu4l5PVJLM=; b=y/dY49q+LkF/rvnW9DKxRd97Uo71fE+2Sy4xMTjYoGa5bfC5WQQaZPetNYfqWA9b++ +1ErCBU6ruBwc5Ttd4gqy6MmDA6i8mUSWMZ/lIVLYraPyKErGe4IWwvLR9TRF3h84emb 7YjFgAqffi7191SnSmeHMWoAb/CWWS0AN6voMRKp9lO/j5KvnFieELJOce3kQzpb2ZlK CtSPFMKBEJELX0hDXh/yT0b6Hi4JjY9KywyPnmSF3TB7tmxF304H4RxhJ82h/g+I843F F7VMphaww0Xdrd4UcGa51bIEPFhtRmGRwfZuUpzcD/HjydZ3o0VtDeWwHyAmrTKZi0Bm jJcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bHsaFDo+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m33si23475130pgl.379.2018.11.14.14.26.08; Wed, 14 Nov 2018 14:26:22 -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=@google.com header.s=20161025 header.b=bHsaFDo+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388753AbeKOIaM (ORCPT + 99 others); Thu, 15 Nov 2018 03:30:12 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43896 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388739AbeKOIaL (ORCPT ); Thu, 15 Nov 2018 03:30:11 -0500 Received: by mail-pg1-f193.google.com with SMTP id n10-v6so8004568pgv.10 for ; Wed, 14 Nov 2018 14:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=L4pSjUmIOTE0zfl+uSAhUu8uxkMsgvMqkVu4l5PVJLM=; b=bHsaFDo+/Xp1Htf7bc1MJT/ArLhDCAld3LslMWj8wWkw2iq2Hj4HSgGXQ1hOcxtuqj frLf0ZITUxUtUnAVmaH5mKdkiVVU1CKRwgk/rjkYH1dYSaRu84QaNUuKdbbdL7WtBxSz i1naaE6Jc+P12tjPIVdSzNNkgfdX0spxF9goubowf9W8DADQkS+X5dqncBactkDOYJxT BVPiqih4MIMS2LW4llPzcKoJJ6P3ifg/+EQ3lwNTS7IuBZPuO7azI345cvUL1P0gLUSg +dMHcuClYt7LNu+vUC/So8dEwyoiPWRhCtldDkuXIqB65KEKdFCHS2vxsVL1QZePRuFV s2PQ== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=L4pSjUmIOTE0zfl+uSAhUu8uxkMsgvMqkVu4l5PVJLM=; b=olXDj9hrbq7uBUhWPIKv93dvoVj9dGt/dOG3HeX5qKAh2N7++JeRtzEIZeZwqf0BMb OK8Gm7I7vHH0cHvoZd8sfGV2b974oc5JDgl5dPrl+3WqC9viBIIR39h/oZllKHxpL9um 6OnFdJRrXrGY92YpTMB0HC+UMdG0EMYFspFniRpRRwRj/4faN/MVAwoSPA8tMVleQq8w 52vaj7/TfPPfm1l4tJwdRMf9BQ2nAh8qtQ0pNZ7dGCNQF5AqP2yNTZ9m49SpgIubQw6J n8PhmLd8bJuPi9suMn5PqJtcMRgWkcVEuq7PdwJDYMJdVKnwSFjLuAY9THhJVY2sgDsv d6Lg== X-Gm-Message-State: AGRZ1gIDfE/WO3Zvip3qTrLLE//LkjBcR75IyaZZQI/q4f47pNYvKbkk 2UKZzVbpYD9x84pJLyoXwQS73w== X-Received: by 2002:a63:ec13:: with SMTP id j19mr3429999pgh.6.1542234306779; Wed, 14 Nov 2018 14:25:06 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id r81-v6sm54878447pfa.110.2018.11.14.14.25.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Nov 2018 14:25:06 -0800 (PST) Date: Wed, 14 Nov 2018 14:25:05 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: "Darryl T. Agostinelli" cc: linux-mm@kvack.org, cl@linux.com, bvanassche@acm.org, akpm@linux-foundation.org, penberg@kernel.org, vbabka@suse.cz, iamjoonsoo.kim@lge.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Suppress the sparse warning ./include/linux/slab.h:332:43: warning: dubious: x & !y In-Reply-To: <20181109022801.29979-1-dagostinelli@gmail.com> Message-ID: References: <20181109022801.29979-1-dagostinelli@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 8 Nov 2018, Darryl T. Agostinelli wrote: > Signed-off-by: Darryl T. Agostinelli > --- > include/linux/slab.h | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/include/linux/slab.h b/include/linux/slab.h > index 918f374e7156..883b7f56bf35 100644 > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -317,6 +317,7 @@ static __always_inline enum kmalloc_cache_type kmalloc_type(gfp_t flags) > int is_dma = 0; > int type_dma = 0; > int is_reclaimable; > + int y; > > #ifdef CONFIG_ZONE_DMA > is_dma = !!(flags & __GFP_DMA); > @@ -329,7 +330,10 @@ static __always_inline enum kmalloc_cache_type kmalloc_type(gfp_t flags) > * If an allocation is both __GFP_DMA and __GFP_RECLAIMABLE, return > * KMALLOC_DMA and effectively ignore __GFP_RECLAIMABLE > */ > - return type_dma + (is_reclaimable & !is_dma) * KMALLOC_RECLAIM; > + > + y = (is_reclaimable & (is_dma == 0 ? 1 : 0)); > + > + return type_dma + y * KMALLOC_RECLAIM; > } > > /* I agree with you that the function as written is less than pretty :) How does the assembly change as a result of this code change, however? This will be in the kmalloc() path so impacting the assembly to fix a sparse warning may not be warranted.