Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp460798lqb; Wed, 17 Apr 2024 01:12:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlz/CBD+AMnNm7nkzmu3DSeK61Z3xmhDVw57QMx8ukbDEwnxCuL/5so3jrT4AZg03UDbSqTp3q/pxTBJhqI/hmCodpZc3rbOZgsa2htQ== X-Google-Smtp-Source: AGHT+IHLmzbRcmiDMjVrf1Hto9/Jscd6leHZw94z/t4Ue03emW5tdHOZouhhWmbQvG13Og3SjAQ4 X-Received: by 2002:a17:90a:d310:b0:2a5:7e31:5030 with SMTP id p16-20020a17090ad31000b002a57e315030mr13149219pju.15.1713341555357; Wed, 17 Apr 2024 01:12:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713341555; cv=pass; d=google.com; s=arc-20160816; b=Ly0NrgyaVOcJCwdV9/ci/73G4JM3AD+4YdKxTIInuYX2IfRxQB6eM9qiVNtaoj09xC YMNf7xwmip7SoYF0hlMZpuCuzIEGUGu0+Iumj5NeIS8kd9iWvocQeoWaAvdLUc+Mp0+0 vVldSYMIyZLaRqfMrpbx+KUIBub22iYAPaCoGUEd9YkgUyvpXse+6MJtEJ4F1J6RV8Qx d+bZpT62/HVOwXABhpYw8rpUmYK/fIjYel6vAPCCX/FfP/YFsH/k0SrYgmCrtygGpFzB W4zAARUNiJanz5kQ8CnX6dEqz2Ul5XN9hB3jycu4ghW/nJoWj9KnI8VCwk4xlkzPJWh7 54Ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=4utM/Sl9d7qVlWh5DitFl//HRd0EeK+V3m+eOFZIrrg=; fh=i3h0zFpO30BMmRQ17XbqxW/N6Jd8Q5Xi1yZjBhqT0WA=; b=v8UOMh0SiTSfmuAm2/v4GjoOkCF7vlTHJHWevBPpS32UpVTtdSJA4wQe6nfGlly70X yHsYpZFIpSsOCFitJNyS/nSVryv1DIWYakNgvKzEs/vpEtvxv2qOkUFmPS1DoJ5l3zxv BVtIUYs4j8rmQsdplwQpJ2AixrTPIjmZVTx/a3iS8qRv3tSypgEXBeGdQRntFDe8APTH 3WSkbW77dD4k4z2f4BmqTzQFMHKvM9mKNjgqhrUWF84Yz7ovApi1FAb03M47/sSteXRH 1yjLZbAAObI4dDHn9D30A5tJE5B33hDfq/6pqlLw1nCZ196dIFuUimcRu9j98wJDWPSX 6DYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=DKEUcC1e; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-147815-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u15-20020a17090a3fcf00b002a046fecedcsi858679pjm.41.2024.04.17.01.12.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 01:12:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147815-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=DKEUcC1e; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-147815-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1A4FF284A43 for ; Wed, 17 Apr 2024 01:04:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E584C1FC8; Wed, 17 Apr 2024 01:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="DKEUcC1e" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E13463B8; Wed, 17 Apr 2024 01:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713315880; cv=none; b=rUnp2FRkTwPPnU9ojCF39ilQlhMzdnhwMFeCfv60n41fpVt0evC0Bbm2mZ94ZFH9FiK9MYOtu/ZwhWp8KITI5o6t5p76m8NmdEoykE1wLpKv45JCfjKZJQ2CWuRo4V5hwcrDuKtMJtmCrLYp7cYaVXZHuaSSiQ5/nBtBTe89OuQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713315880; c=relaxed/simple; bh=hQttcr/K+L2TZzpAmTtlhuqzh30BQG44N5VEGmk/0w8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YiHuWf/XMD4kR73iI+sJzl2/OmbvmxSpyhe8QVn9ItNFxuB2sSqYCgJ35w6IBFNUelftsMpgaEK0GJAUTXeDfOhDI4ycFHcZ1gMJFbufVlskFdnI9oT/hvuYj5TK4Jgk/REXjOerzMUZc65CQZxLuoWpe/35FXE31oRHb4QIi2Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=DKEUcC1e; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=4utM/Sl9d7qVlWh5DitFl//HRd0EeK+V3m+eOFZIrrg=; b=DKEUcC1el2eewz7Hw202gFRAEF puke5nCdVc89xvbsGo8hLzAssnxfBiTnjbSosHTkdroVYv4zjRgJd19bQKKX2Tc6CLy3Ezfi9J1K8 /zrv4vSJJaDQow/L271Uft6UMm3a8ueBdi1F9pyvEgzB6ciyExb1K6Cqoeaiwtm/MKQo1pgAso8Xf q6gDDgXyZ6jf/7uRadvYgutjdZvB+KgtGyl+zjTcUi2cd15XeePPbz/l3+mfW+oRT8DTxoHSAUHBb e72BrrFw/CUOw8D2M1rcuk78y4g5c8ZiFNtyX7RmHDOKlUbZyigoQflFjOa03Ea2kf3+c8apvIs4e NhTMBmqw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rwtiw-00DuLU-1h; Wed, 17 Apr 2024 01:04:30 +0000 Date: Wed, 17 Apr 2024 02:04:30 +0100 From: Al Viro To: David Laight Cc: Christophe JAILLET , Christian Brauner , Jan Kara , "linux-kernel@vger.kernel.org" , "kernel-janitors@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" Subject: Re: [PATCH] seq_file: Optimize seq_puts() Message-ID: <20240417010430.GB2118490@ZenIV> References: <5c4f7ad7b88f5026940efa9c8be36a58755ec1b3.1704374916.git.christophe.jaillet@wanadoo.fr> <4b1a4cc5-e057-4944-be69-d25f28645256@wanadoo.fr> <20240415210035.GW2118490@ZenIV> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro On Tue, Apr 16, 2024 at 08:56:51PM +0000, David Laight wrote: > > static inline void seq_puts(struct seq_file *m, const char *s) > > That probably needs to be 'always_inline'. What for? If compiler fails to inline it (and I'd be very surprised if that happened - if s is not a constant string, we get a straight call of __seq_puts() and for constant strings it boils down to call of seq_putc(m, constant) or seq_write(m, s, constant)), nothing bad would happen; we'd still get correct behaviour. > > { > > if (!__builtin_constant_p(*s)) > > __seq_puts(m, s); > > else if (s[0] && !s[1]) > > seq_putc(m, s[0]); > > else > > seq_write(m, s, __builtin_strlen(s)); > > } > > You missed seq_puts(m, ""); Where have you seen one? And if it gets less than optimal, who cares? > Could you do: > size_t len = __builtin_strlen(s); > if (!__builtin_constant_p(len)) > __seq_puts(m, s); > else switch (len){ > case 0: break; > case 1: seq_putc(m, s[0]); > default: seq_write(m, s, len); > } Umm... That's probably OK, but I wonder how useful would that be...