Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2121509imu; Tue, 6 Nov 2018 09:21:23 -0800 (PST) X-Google-Smtp-Source: AJdET5f4A5wVcYSS+/318eDwqyKKY3eMU1W39gTYEr9Nx5aCnAw55mO1hRk+Sm/IWyc56awHp5UT X-Received: by 2002:a63:2e02:: with SMTP id u2mr4633113pgu.9.1541524883132; Tue, 06 Nov 2018 09:21:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541524883; cv=none; d=google.com; s=arc-20160816; b=OegxqVvql9kefPu5f9/zH7h0tD8p8IawyBpTfe5jkuhnhgnsS0TWaPdJef4kd/eHvr RCbXVbCgDS8+hx8HMfXolST/BKuR4p0Scx3NuaN3t/oYNQVr7ac7s1mrbO/fgcBFVHcv 961UvU6Jb/97aNvUYDWQufSulpcz4o2QcThNZbn4nmUTJXGjevFUlrVDwfVn3DXnGIXV 5q423Agk4m6t9VQq/eXjTawoUnHMErunOUxmuAC4tLVNCoC8q39dPdrKIBVOYVGnZaK9 a7Lj0WMuAFuw8K1kQxGaSW5rACTcK4F0KMeeYQZAcEF/eRFyIBMZb1/mbaqnzejujaiX Otmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nOkwPCRa3hxcXAFWPhipuDjsmzUilHzyYbPhcCW2B90=; b=ng6OYjfLJSqIgZERXsF8cR3kpWjD8SZZJZ02ER5wGKHhrD0ZfVp1VHsgm19e0oxSC+ ttXBdZxog2p4S9HeUH0MikpVar1TlOyT/GENovZh/gF3M4siBvf/SBAiN79yvHOwyF8t HwsSQmx/UUAjlk4p6drtbeLpVwiGQgf+DBp2EVFxBwWO1hKz03a+GNK5q/GINsYduH/J n5YxJF9AG8DrLOINdDtzD4p8RUmqOefukxs5fiH8hLCTU6Jq3WsyAxbOsT11xBHw98R3 nSeZfjfLXelYIqs1iIGkQGbalcQFwmh3EKjN6al94zJca4HhaB/EaxPFMSuQzUdexZS6 T3aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pusHi1N6; 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 bj7-v6si4587921plb.193.2018.11.06.09.21.05; Tue, 06 Nov 2018 09:21:23 -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=@gmail.com header.s=20161025 header.b=pusHi1N6; 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 S2389459AbeKGCqe (ORCPT + 99 others); Tue, 6 Nov 2018 21:46:34 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:55516 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389303AbeKGCqe (ORCPT ); Tue, 6 Nov 2018 21:46:34 -0500 Received: by mail-it1-f194.google.com with SMTP id b7-v6so18930872itd.5 for ; Tue, 06 Nov 2018 09:20:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nOkwPCRa3hxcXAFWPhipuDjsmzUilHzyYbPhcCW2B90=; b=pusHi1N6gKldFjCsy+TzZgaFO68GmBCxPGHbLqJR72FpinAu9VhS0ZkJsYdGzvCP5c tPjrtqMsU7yZHVy0SD4jJcaXEoxQ6HBdiPVbXnpsnBEajzCNKA1G7jyxWiA5fGrq4o7+ Q+zPC0X4p8ZXcFureJOrXcHD6ErlvTszVHdGJt2pXp37/TrhneNC+tVqr0dGcCq4gXbU 8/O42cIMwqkZR4etlJB35RaUFQ31iBvVqBhow4y7bBCHqFzd9FJ8mjWo2eIQ5KJ9SYfC KgyJKrFQJyDsUuxZ7dziWqkg8UwpgtTBBzvqfHvx6/HUNVMrPHmZnRwrdk9gGclcaTiG 5Bng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nOkwPCRa3hxcXAFWPhipuDjsmzUilHzyYbPhcCW2B90=; b=cbEdABHcL2nWWM9EuwiKrov+SQ+jGbI1z/CKPafCMbWtk1ycvpMB6wCvpgszS2RUfo istFMOe3BuEiSEnqUnMaeGgsBKCokAV2af0ASP92LQ8ihSbtccr0ryoBWesC+taufPHU doiz3HKumHG6Wb9W+KFmPSRDFZDhXtHBVkYiUyuaE/2FSBPND00tx+jGT/ugUDNBP0Eu ltavqG84wFbP6gbmUa5A6ZakuWELAAzV3GNiHPI96noN2SfSVgLxvIGZnfvkdptkp9JL /zlXAhB68+Km5t2XjOFPQBF1Lq7cOnHXiaoJN0Es0Bb0VTBLQOrDd/8+6Pkgb4YCMLxA Oyng== X-Gm-Message-State: AGRZ1gJXJ2QOS48iqBPzxlF7ks+iEuNDLnG6ODjeXl7w4awy2EZV+nto xvUIRfvHkYwz69Ugx37D5ZXOAB42MjkPDOd4gJM= X-Received: by 2002:a24:5308:: with SMTP id n8-v6mr2754878itb.146.1541524821429; Tue, 06 Nov 2018 09:20:21 -0800 (PST) MIME-Version: 1.0 References: <20181105204000.129023-1-bvanassche@acm.org> <20181105131305.574d85469f08a4b76592feb6@linux-foundation.org> <1541454489.196084.157.camel@acm.org> <1541457654.196084.159.camel@acm.org> <1541462466.196084.163.camel@acm.org> <1541464370.196084.166.camel@acm.org> In-Reply-To: <1541464370.196084.166.camel@acm.org> From: Alexander Duyck Date: Tue, 6 Nov 2018 09:20:09 -0800 Message-ID: Subject: Re: [PATCH] slab.h: Avoid using & for logical and of booleans To: bvanassche@acm.org Cc: linux@rasmusvillemoes.dk, Andrew Morton , LKML , Vlastimil Babka , Mel Gorman , Christoph Lameter , guro@fb.com, Pekka Enberg , David Rientjes , Joonsoo Kim , linux-mm Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 5, 2018 at 4:32 PM Bart Van Assche wrote: > > On Mon, 2018-11-05 at 16:11 -0800, Alexander Duyck wrote: > > If we really don't care then why even bother with the switch statement > > anyway? It seems like you could just do one ternary operator and be > > done with it. Basically all you need is: > > return (defined(CONFIG_ZONE_DMA) && (flags & __GFP_DMA)) ? KMALLOC_DMA : > > (flags & __GFP_RECLAIMABLE) ? KMALLOC_RECLAIM : 0; > > > > Why bother with all the extra complexity of the switch statement? > > I don't think that defined() can be used in a C expression. Hence the > IS_ENABLED() macro. If you fix that, leave out four superfluous parentheses, > test your patch, post that patch and cc me then I will add my Reviewed-by. > > Bart. Actually the defined macro is used multiple spots in if statements throughout the kernel. The reason for IS_ENABLED is to address the fact that we can be dealing with macros that indicate if they are built in or a module since those end up being two different defines depending on if you select 'y' or 'm'. Thanks. - Alex