Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1014063lqt; Fri, 19 Apr 2024 19:21:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWkgGhwXg928890LbgzfPrIRB59yb8iaA0MrktTnNa2cDzy9pvEFaP8glESvkEwaUBLnARa/5v3hUjLryfUAL1YZUi4IdXRQAotiTnL+w== X-Google-Smtp-Source: AGHT+IEUMtnYG1/LKhk84UtI1GotJ1tTYZJSMdvQi3aCK22DHHVJ+VxJ/K/j8HCg4GAWtBDohDFF X-Received: by 2002:a0c:eda7:0:b0:691:e21:736c with SMTP id h7-20020a0ceda7000000b006910e21736cmr4113568qvr.30.1713579708293; Fri, 19 Apr 2024 19:21:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713579708; cv=pass; d=google.com; s=arc-20160816; b=f5Z5U1QbJLTaArDEH5U4kYWmXli7hj4lqVjJrtXMg6XaA5k7EYtvP0prRzmWMOxU2O BsX6vVDzcHBtiVpOhRLIkE/CfMKfZeyKNV6hj9Ti81JJoFJH7T1xoWe5IXZwyyTNCvdi tA7bu3cFkmXEeBm/wc8s8Jc4gq4p6YMRbj2SoHkuw3JdSUb8jiiPIOQf7qZPe10VBMSk noJwaFMdJTUIRjnc135A26fn6CRWgIpW3dXDOYmu0oam28h0IAP0U+BQv/8Wg06i6wc/ lUMmpiHq2pz9RfRxzYSg6hMsEkfAybRIX1QbViCcMwidwUGoUtztKLBa0iW23Nf2/S6E e5vg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BSbfcQ7mq/v3QwnrqUlPv0jIW1VWZRhaDa+hlEmn1xA=; fh=I2RmSD6jldpxL7HToPBO98gaCupDs6mFQGyLKKp1Pms=; b=GYPtAEYN0gWV4kx/RtjeH/Wj/STyQ344IJcxoG8RcFsWnCuN+7TmTnA9NxnS9X8c/7 8umRRtk3Wwnqbee3pjao3sDvEWCPbpUxGRXHeLvHSLwsk5bshYYmOMCVKIMVe8uopo0n GF92QtkM4rc/7ZrjLtGi+gvziwomv/3QLhx3WqUiT0WssHlxJFzniIlEDzPz043c0Nhr Vh0vfgmLXiaB17aFommZIZga3BN9xnW95cv8t5e0rceq3gpIc1KFcqMHqfvkWrc+df4M 3aidtq7MMsNpPCDAHWlui+H2FzA9bGZtBwzQ0QUPgpaDXD+YvqCE7u7OXzetOWEFXO9L QoHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=itVp2F74; 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-151973-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151973-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 ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 2-20020a056214202200b006a0428d6c0fsi5369727qvf.437.2024.04.19.19.21.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 19:21:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151973-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=itVp2F74; 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-151973-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151973-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 566581C21423 for ; Fri, 19 Apr 2024 21:33:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86C0613CFB5; Fri, 19 Apr 2024 21:32:52 +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="itVp2F74" 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 6D0F612DD97; Fri, 19 Apr 2024 21:32:48 +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=1713562371; cv=none; b=B1IAbTiQvjxtXjKcZqXhKJaXFa4uUvAOeGQjOTNXvhBDHqAbYX39Mokr91Th+dp488O3InC6g9ejMr1WhuX8onElNb8FSe5pf6kZZ+JrQHBri/y82k2an8Q3h6BZlRDX1lkbvfkweZsq3FsKxUbVJIYJdl9WctGDFvEQ+uPeVYI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713562371; c=relaxed/simple; bh=B2iZnJTC4U4cJAnQgyN7BqEuOSFQX6ioLbcIUsDWQ2A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LK1cRnpdWoko1wQXhkuPA8GnXKk+QDk9q2gl/8JE/8tJF+nQ1p0AtJ/ZTb3HkbsNxAwJbtJ3BnE+/s4EmUOx5lV338G2/qxV1EEW7F347ovgkO7DYcYJuac6NWc5qiW3volo/En+LqjucSuI7jlUiZC3Zg2dPDoICpeRL45nY7E= 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=itVp2F74; 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-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description; bh=BSbfcQ7mq/v3QwnrqUlPv0jIW1VWZRhaDa+hlEmn1xA=; b=itVp2F74WuIvR2DEge0CZPHYjJ e7rw8X2SioMwT2jsL0nciCUwrmGrq/4G/alY0u+k34cNqlsEKRpCuFoIr9owJGypggKiecCetAi2O dI1C4SyAQzzfKfB7W8WQ/CQopIALH+mz1jscTSt+iv1nTIscnGhZJJszVrHSiteykrnulu4dN0Y95 Y49qyBhuhT+ojpaCUsf+vTCjA+fgrdmS8Cvs+I/O3d03nLeUMuIJD41CXBCkXzNWyGSWC7X9qDIDO Z2C8yxjfbLHVmRJzxyOraaBuylRqFCjOi3i+Q8hDLGnszBPkvRrTTZ9Uos0OQjugRTDQGqbREw/RB WJWMiFBw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rxvqa-00GgxV-1E; Fri, 19 Apr 2024 21:32:40 +0000 Date: Fri, 19 Apr 2024 22:32:40 +0100 From: Al Viro To: Christophe JAILLET Cc: David Laight , 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: <20240419213240.GE2118490@ZenIV> References: <5c4f7ad7b88f5026940efa9c8be36a58755ec1b3.1704374916.git.christophe.jaillet@wanadoo.fr> <4b1a4cc5-e057-4944-be69-d25f28645256@wanadoo.fr> <20240415210035.GW2118490@ZenIV> <5e5cde3e-f3ad-4a9b-bc02-1c473affdcb1@wanadoo.fr> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5e5cde3e-f3ad-4a9b-bc02-1c473affdcb1@wanadoo.fr> Sender: Al Viro On Fri, Apr 19, 2024 at 10:38:15PM +0200, Christophe JAILLET wrote: > Le 16/04/2024 ? 22:56, David Laight a ?crit?: > > From: Al Viro > > > Sent: 15 April 2024 22:01 > > ... > > > No need to make it a macro, actually. And I would suggest going > > > a bit further: > > > > > > static inline void seq_puts(struct seq_file *m, const char *s) > > > > That probably needs to be 'always_inline'. > > > > > { > > > 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, ""); > > > > I did wonder about checking sizeof(s) <= 2 in the #define version. > > git grep seq_puts.*\"[^\\].\" | wc -l > 77 > > What would you do in this case? > 2 seq_putc() in order to save a memcpy(..., 2), that's it? Not a damn thing - just have it call seq_write(). Note that if (s[0] && !s[1]) which triggers only on single-character strings.