Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1143468imu; Mon, 5 Nov 2018 14:48:05 -0800 (PST) X-Google-Smtp-Source: AJdET5dolmof9rDD0Dfz9vgy4+a1M4+jcfge+xJufcngZZBMvnEX8xeVu4ktlR/QQfmPIHlhtKNk X-Received: by 2002:a62:c42:: with SMTP id u63-v6mr23992728pfi.43.1541458085934; Mon, 05 Nov 2018 14:48:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541458085; cv=none; d=google.com; s=arc-20160816; b=d1teokGj5jY2TxrcZFSVS+YdhZhi/oa16VVXFddRPMwzsA49eynEb6W5zTiMStFbf2 +5GaHgDDsWGW3mRM/o3uSkZcUmu1mIXnpq1DqrNlc3HV9ZbFOiebPRRgaJQVQYLoaQiN W023Be4eIRRXz2sJNZ0Mz7/eTq+uxseI/ZDsrqcPeK6vA7YBK3Q0NxDiROhQMGv6naa6 lrHcncswHZyPZGxcyjTWGxLozyr4Yg3ipnSE/9+Pmu18gtwmeRbCfuelJ1kNRjgdMLL/ QYIStti76E9xzllbtaOcqS00hC8gN998JvtnrMm37VTmpkn+rW2owQb5g/++7eZcktXc i5mQ== 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:date:cc:to:from:subject:message-id; bh=MiqoocSfYqtwTjMheZJvjB4bRjcTx6Up2mHhgWKrdjE=; b=in3sGeWgvfXUI+mghtkkZdHlzH8YZi41b1SIdmGVS74oD5AEzPmfUgrfEPWaO3zyYO wzwgkn5er5k8wN9yij3dFBQM8sd3Esgya1syqRKdjqXMReCnm7b107zLQGElu6ZfJVXA hALVFzOZyQI+wj9vA848QsGAmNUHrZJssMIIDJLh5XqYRAwB82MwEGEFTtO0TKe14/fh +3fPwar+TQqDqCywi5XuOWejgQzdP+7GAVdHXjSG/MFHi06dld2s+w9hrhmmsWHvtxKj JQ43RwX/TLnkP6ryxKgWnNkY+2JUrVMelS9AM6Jcg6fjgSGMqIVPtnvx/Qlnm+t/lcL9 iyeg== 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 f38si3874645pgf.206.2018.11.05.14.47.49; Mon, 05 Nov 2018 14:48:05 -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 S2388186AbeKFIJP (ORCPT + 99 others); Tue, 6 Nov 2018 03:09:15 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42039 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387965AbeKFIJO (ORCPT ); Tue, 6 Nov 2018 03:09:14 -0500 Received: by mail-pf1-f195.google.com with SMTP id f26-v6so5118348pfn.9 for ; Mon, 05 Nov 2018 14:47:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=MiqoocSfYqtwTjMheZJvjB4bRjcTx6Up2mHhgWKrdjE=; b=Bu37F46tFQQhtyTe9w9/aPF05RmLVg7jFLYMNWKVWrd0a7zvrP30bpFT9QYR+fY7mk DqNw5FUiejvLbm2MrrkGTvmGbjARRnUuwy47fZgPuIvru+EgGvNc1CuKoAK9yf5V0MX0 CU6Osny2WCECYb+xmxsSrM/25GwBttuusJqRhrSx4JKqlPTbFYqdKn3RLEQPQ6cuRM3J lqwfJHt6zWQ32uFbLZ2Wyq5s7y8aO0EHKdhQtDcvuOMnKcabVr7e2bt6Q3PsQTCgLrye WtKJUPjeP3g5MPw/IvWmjYL5BvscmspTzIaK22bGxTlYyrsnT5cLtblKBZ2Kpj2pb3p9 3wuQ== X-Gm-Message-State: AGRZ1gIzXdTg4ZniOr77EXRzQYIEsn0gvtDpU6NQ2kEYNB6BLD9mS+Rn 4xijE8G1gkHT7TTQJz34C3k= X-Received: by 2002:a62:704a:: with SMTP id l71-v6mr9133647pfc.68.1541457657531; Mon, 05 Nov 2018 14:40:57 -0800 (PST) Received: from ?IPv6:2620:15c:2cd:203:5cdc:422c:7b28:ebb5? ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id p14-v6sm51529998pgn.45.2018.11.05.14.40.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Nov 2018 14:40:56 -0800 (PST) Message-ID: <1541457654.196084.159.camel@acm.org> Subject: Re: [PATCH] slab.h: Avoid using & for logical and of booleans From: Bart Van Assche To: Rasmus Villemoes , Andrew Morton Cc: linux-kernel@vger.kernel.org, Vlastimil Babka , Mel Gorman , Christoph Lameter , Roman Gushchin , Pekka Enberg , David Rientjes , Joonsoo Kim , linux-mm@kvack.org Date: Mon, 05 Nov 2018 14:40:54 -0800 In-Reply-To: References: <20181105204000.129023-1-bvanassche@acm.org> <20181105131305.574d85469f08a4b76592feb6@linux-foundation.org> <1541454489.196084.157.camel@acm.org> Content-Type: text/plain; charset="UTF-7" X-Mailer: Evolution 3.26.2-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2018-11-05 at 23:14 +-0100, Rasmus Villemoes wrote: +AD4 Won't that pessimize the cases where gfp is a constant to actually do +AD4 the table lookup, and add 16 bytes to every translation unit? +AD4 +AD4 Another option is to add a fake KMALLOC+AF8-DMA+AF8-RECLAIM so the +AD4 kmalloc+AF8-caches+AFsAXQ array has size 4, then assign the same dma +AD4 kmalloc+AF8-cache pointer to +AFs-2+AF0AWw-i+AF0 and +AFs-3+AF0AWw-i+AF0 (so that costs perhaps a +AD4 dozen pointers in .data), and then just compute kmalloc+AF8-type() as +AD4 +AD4 ((flags +ACY +AF8AXw-GFP+AF8-RECLAIMABLE) +AD4APg someshift) +AHw ((flags +ACY +AF8AXw-GFP+AF8-DMA) +AD4APg +AD4 someothershift). +AD4 +AD4 Perhaps one could even shuffle the GFP flags so the two shifts are the same. How about this version, still untested? My compiler is able to evaluate the switch expression if the argument is constant. static +AF8AXw-always+AF8-inline enum kmalloc+AF8-cache+AF8-type kmalloc+AF8-type(gfp+AF8-t flags) +AHs - int is+AF8-dma +AD0 0+ADs - int type+AF8-dma +AD0 0+ADs - int is+AF8-reclaimable+ADs +- unsigned int dr +AD0 +ACEAIQ(flags +ACY +AF8AXw-GFP+AF8-RECLAIMABLE)+ADs +ACM-ifdef CONFIG+AF8-ZONE+AF8-DMA - is+AF8-dma +AD0 +ACEAIQ(flags +ACY +AF8AXw-GFP+AF8-DMA)+ADs - type+AF8-dma +AD0 is+AF8-dma +ACo KMALLOC+AF8-DMA+ADs +- dr +AHwAPQ +ACEAIQ(flags +ACY +AF8AXw-GFP+AF8-DMA) +ADwAPA 1+ADs +ACM-endif - is+AF8-reclaimable +AD0 +ACEAIQ(flags +ACY +AF8AXw-GFP+AF8-RECLAIMABLE)+ADs - /+ACo +ACo If an allocation is both +AF8AXw-GFP+AF8-DMA and +AF8AXw-GFP+AF8-RECLAIMABLE, return +ACo KMALLOC+AF8-DMA and effectively ignore +AF8AXw-GFP+AF8-RECLAIMABLE +ACo-/ - return type+AF8-dma +- (is+AF8-reclaimable +ACY +ACE-is+AF8-dma) +ACo KMALLOC+AF8-RECLAIM+ADs +- switch (dr) +AHs +- default: +- case 0: +- return 0+ADs +- case 1: +- return KMALLOC+AF8-RECLAIM+ADs +- case 2: +- case 3: +- return KMALLOC+AF8-DMA+ADs +- +AH0 +AH0 Bart.