Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp530143ybe; Wed, 4 Sep 2019 03:49:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+o+zk7a37dmUIID+l4hu8SlhtRVekBXkDTwiAz2DScUbX1YhcSyErTcdCab5RZkfKe7me X-Received: by 2002:a63:188:: with SMTP id 130mr34110941pgb.231.1567594145132; Wed, 04 Sep 2019 03:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567594145; cv=none; d=google.com; s=arc-20160816; b=kwXa8qXUPZ3I5sNYTY9ehcDfR+fgBIwiUUn35og9LXXnBt7ptC+9OhclLvn8gwfchg MkkyrNntFt09Fweh5Bn1zIO3CbiYkhI/wkiRxZx6nu+ZVRJv3ojdUKeKTxFPQWT5u/e5 6scPi5hPQkxeKQmuZrJDYz6rCDbdMJ42N7PeTLY2UUvQ9GCPNONEtuh5uPj6pKTIxcuh chjF4bP0LqQoVJGdhrMyJHMZhYM4faKnKXClmAV+Sur9ggO5ClP7urteOat1uX9yZvm8 RjMxWBvHuESil+syryw31nuS7oUx5Xvug4EVCjTFe1jdD8oQNIPn4z7Y6aiFm0x4n9Sc exJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=299jd8Ja8DoZd0u99D++XoJfGuK0wHkOAZp57zddDRM=; b=jDCRLqR8LVOYl9lLZQJ1xqn9kH76uG9HRJKifoGHWH4Gmhl/L/N62msqmz4q3IyVVd dz4PnjUOI2QcWJ2QxJrjOFYlJQa59ZzWZfs0fxHRPpkq35D9PSFsGOq7aDJ8TkGBFr37 GJ0stJMV13/Pd2A5kF4H3pq2hfv6LGTRx2bwjjrYTytHLY4PUi7G3uGfwkl2MV7q6gsC sDxu3Z+UIj0aykoUh9GvQR66Dqvg1MN1p0RiVjwsM4JFbq0qj9s50HL3I6Rez21oIx8J LdK+uklhf/2Qvh31pQxHjUAKkHkfNYec4XSnMxG58w0fsZVF9AJ40bQ97UtOVD/cg19Y +sKw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u23si857397pfh.53.2019.09.04.03.48.48; Wed, 04 Sep 2019 03:49:05 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729423AbfIDKsB (ORCPT + 99 others); Wed, 4 Sep 2019 06:48:01 -0400 Received: from mga14.intel.com ([192.55.52.115]:34529 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727722AbfIDKsA (ORCPT ); Wed, 4 Sep 2019 06:48:00 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 03:48:00 -0700 X-IronPort-AV: E=Sophos;i="5.64,465,1559545200"; d="scan'208";a="176903236" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.161]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 03:47:55 -0700 From: Jani Nikula To: Rasmus Villemoes , linux-kernel@vger.kernel.org Cc: Joonas Lahtinen , Rodrigo Vivi , intel-gfx@lists.freedesktop.org, Vishal Kulkarni , netdev@vger.kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org, Andrew Morton , Julia Lawall Subject: Re: [PATCH 1/2] linux/kernel.h: add yesno(), onoff(), enableddisabled(), plural() helpers In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20190903133731.2094-1-jani.nikula@intel.com> Date: Wed, 04 Sep 2019 13:47:52 +0300 Message-ID: <87blw049t3.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 04 Sep 2019, Rasmus Villemoes wrote: > On 03/09/2019 15.37, Jani Nikula wrote: > >> While the main goal here is to abstract recurring patterns, and slightly >> clean up the code base by not open coding the ternary operators, there >> are also some space savings to be had via better string constant >> pooling. > > Eh, no? The linker does that across translation units anyway - moreover, > given that you make them static inlines, "yes" and "no" will still live > in .rodata.strX.Y in each individual TU that uses the yesno() helper. I should've been more careful there; this allows us to do better constant pooling but does not actually deliver on that here. You'd need to return pointers to strings in the kernel image. The linker can't constant pool across modules by itself. Anyway, that was not the main point here. > The enableddisabled() is a mouthful, perhaps the helpers should have an > underscore between the choices > > yes_no() > enabled_disabled() > on_off() > > ? I'm replacing existing functions that are being used in the kernel already. $ git grep "[^a-zA-Z0-9_]\(yesno\|onoff\|enableddisabled\)(" | wc -l 241 Not keen on renaming all of them. >> drivers/gpu/drm/i915/i915_utils.h | 15 ------------- >> .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 11 ---------- >> drivers/usb/core/config.c | 5 ----- >> drivers/usb/core/generic.c | 5 ----- >> include/linux/kernel.h | 21 +++++++++++++++++++ > > Pet peeve: Can we please stop using linux/kernel.h as a dumping ground > for every little utility/helper? That makes each and every translation > unit in the kernel slightly larger, hence slower to compile. Please make > a linux/string-choice.h and put them there. *grin* In the absense of a natural candidate in include/linux/*.h, I thought shoving them to kernel.h would provoke the best feedback on where to put them. A new string-choice.h works for me, thanks. :) BR, Jani. -- Jani Nikula, Intel Open Source Graphics Center