Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1099280imu; Fri, 9 Nov 2018 10:55:18 -0800 (PST) X-Google-Smtp-Source: AJdET5cITlPyJx6xggQfxNYgSXEK9MBnXfxyRIppM5CfkbaqR07JZBiPhPxxtj01uxXPSid9YHpH X-Received: by 2002:a63:f047:: with SMTP id s7mr8402191pgj.441.1541789718825; Fri, 09 Nov 2018 10:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541789718; cv=none; d=google.com; s=arc-20160816; b=Pp6g4wihewPYpeOXIVjyeUoOsSZEXYO1WOvtFQz/58ZOraFMry10LkzK7z6T7VJR2u DVoNgOsHImnrKd19nwDbiFrFX87/LzqMQGojTGpT/BqRomGu0yVMNl/vP9t8x3L85iG9 NCk+YGQNmjXPXM6vVDx3p7jlwWbKn8bCxPE9y9YqFAv6kXa/SJBSbSiQksAHC0XOEtcc Bqp2G9jwQWaZxd2sAi4K+5A3D9R9Dk5f7/YENtD63Xu+sJbLpXlB4cRIk4wHFBsvI+dp HJHnnYqvrBB1lOafe33tkPQO6b4uCD63GtwOiyUDjUVG1/+7WiW5IjrzczsFMJRTT4iA UROQ== 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; bh=OSBJDlpTyIHymYFmdNSrbI8eRbkI+OEowEXnnd4yRVQ=; b=o3VeDUrjIm2Tlw35W3Lr6BTzmHpXVwFmsytx877SY6GnQubvlEYBVdbbGKdClzRwRi 57q88eC7CD7TIsZrrXymT0dG3lHbbt5xrQb2ElfwVlxEHAYI7rceH0o/TyyCtk/JLP3M WgY3rB8OTkVbfG/23syGINqCXitDEGxEmpdUyiuBdY+Qi5h9bzlC1VgQtndXsqUKqnZ9 05ePNAeWdIp7eAasZ6lrou1PFKwG7GweslmJRFfUrCU9nT5YkLfkMgHc/kTOMQO3kya4 kgc3QWzor4aIn+qP4UW8Qq3/siVOd57r6ELHgl011TDZjABERkTwj0WcpXXg3S4NTqG1 9PpA== 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 k190-v6si7558628pgk.261.2018.11.09.10.55.02; Fri, 09 Nov 2018 10:55:18 -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 S1728693AbeKJEfH (ORCPT + 99 others); Fri, 9 Nov 2018 23:35:07 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34006 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727961AbeKJEfH (ORCPT ); Fri, 9 Nov 2018 23:35:07 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DF73389B; Fri, 9 Nov 2018 18:53:15 +0000 (UTC) Date: Fri, 9 Nov 2018 10:53:14 -0800 From: Andrew Morton To: Johannes Berg Cc: linux-kernel@vger.kernel.org, Johannes Berg Subject: Re: [PATCH v2 3/3] slab: use logical instead of bitwise operation in kmalloc_type() Message-Id: <20181109105314.c6a6acfa9badba6733c3f72e@linux-foundation.org> In-Reply-To: <20181109093534.15121-3-johannes@sipsolutions.net> References: <20181109093534.15121-1-johannes@sipsolutions.net> <20181109093534.15121-3-johannes@sipsolutions.net> X-Mailer: Sylpheed 3.6.0 (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 On Fri, 9 Nov 2018 10:35:34 +0100 Johannes Berg wrote: > The operation here really is more logical than bitwise, even if > due to the setup the bitwise operation works fine. However, this > causes a complaint from sparse that the operation doesn't really > make sense due to the not. > > Use a logical and instead of bitwise. > > In my (somewhat unscientific) test this caused no differences in > the generated code. > > ... > > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -329,7 +329,7 @@ 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; > + return type_dma + (is_reclaimable && !is_dma) * KMALLOC_RECLAIM; > } > > /* Thanks. There's presently a bit of head-scratching going on over this. http://lkml.kernel.org/r/20181105204000.129023-1-bvanassche@acm.org - please feel free to weigh in ;)