From owner-freebsd-fs@freebsd.org Thu Mar 7 22:48:26 2019 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06E101528A66 for ; Thu, 7 Mar 2019 22:48:26 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (chez.mckusick.com [70.36.157.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F3D1769AA for ; Thu, 7 Mar 2019 22:48:25 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (localhost [IPv6:::1]) by chez.mckusick.com (8.15.2/8.15.2) with ESMTP id x27Mv66I067345; Thu, 7 Mar 2019 14:57:07 -0800 (PST) (envelope-from mckusick@mckusick.com) Message-Id: <201903072257.x27Mv66I067345@chez.mckusick.com> From: Kirk McKusick To: Alexander Leidinger , freebsd-fs@freebsd.org Subject: Re: 'td' vs sys/fs/nfsserver/ X-URL: http://WWW.McKusick.COM/ Reply-To: Kirk McKusick In-reply-to: <20190307105011.GI2492@kib.kiev.ua> Comments: In-reply-to Konstantin Belousov message dated "Thu, 07 Mar 2019 12:50:11 +0200." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <67343.1551999426.1@chez.mckusick.com> Date: Thu, 07 Mar 2019 14:57:06 -0800 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,MISSING_MID, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on chez.mckusick.com X-Rspamd-Queue-Id: 7F3D1769AA X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.98 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.984,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Mar 2019 22:48:26 -0000 Code refactoring takes (nearly) duplicate code from two or usually more places and puts it in a single function. Code refactoring is nearly always a useful thing to do. It increases reliability because a bug fix in the new function corrects the problem in all the places that the code was previously located. It also concentrates the functionality in a single place which makes understanding easier. Reducing the complexity of a function by removing an unneeded, unused, or duplicate parameter can make the code more comprehensible. That is the point that is being raised here where the 'td' parameter is to be removed because the 'curthread()' routine can be used to get its value where it is needed. Changes of this sort also makes understanding easier. The tradeoff in making these changes are the number of lines of code that are affected. The more lines that are affected and the more files that have changes, the higher the cost and the more developers that are affected. Changes that are all contained within a single file are almost always worth the cost. Code refactoring typically provides greater benefit than reducing the parameters to a function, so can be justified across more lines and files. In the case of eliminating 'td', the cost is thousands of lines of changes in a substantial number of files in the kernel. Nearly every developer would be affected by a change that would have just a small benefit. IMO, the benefit is not even remotely worth the cost. Kirk McKusick