From owner-freebsd-fs@freebsd.org Tue Mar 5 19:59:59 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 8D49B1511159 for ; Tue, 5 Mar 2019 19:59:59 +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 6F1B786015; Tue, 5 Mar 2019 19:59:58 +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 x25K8d4Z011653; Tue, 5 Mar 2019 12:08:39 -0800 (PST) (envelope-from mckusick@mckusick.com) Message-Id: <201903052008.x25K8d4Z011653@chez.mckusick.com> From: Kirk McKusick To: Edward Napierala Subject: Re: 'td' vs sys/fs/nfsserver/ cc: FreeBSD FS X-URL: http://WWW.McKusick.COM/ Reply-To: Kirk McKusick In-reply-to: Comments: In-reply-to Edward Napierala message dated "Tue, 05 Mar 2019 09:26:43 +0000." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11651.1551816519.1@chez.mckusick.com> Date: Tue, 05 Mar 2019 12:08:39 -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: 6F1B786015 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [0.37 / 15.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.00)[mckusick@mckusick.com]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.52)[-0.518,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[mckusick.com]; AUTH_NA(1.00)[]; NEURAL_SPAM_SHORT(0.32)[0.325,0]; IP_SCORE(-0.26)[ip: (-0.19), ipnet: 70.36.128.0/19(-0.09), asn: 46375(-0.94), country: US(-0.07)]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: chez.mckusick.com]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[235.157.36.70.list.dnswl.org : 127.0.10.0]; NEURAL_HAM_MEDIUM(-0.07)[-0.065,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:46375, ipnet:70.36.128.0/19, country:US]; RCVD_COUNT_TWO(0.00)[2] 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: Tue, 05 Mar 2019 19:59:59 -0000 Let me give a brief historical perspective on how we ended up with td getting passed nearly everywhere. It arose in the early 1980's as I was leading an effort to get rid of kernel global user area. The state of a process was stored in its process entry and its user structure. The state needed only when the process was running was stored in the user structure. State needed when the process was not running was stored in the process structure. Thus the user structure could be swapped out when the process was idle. The idea was to keep the process structure as small as possible. On each context switch, the process' user structure was brought into memory if it had been swapped out and then mapped to the global kernel "u" variable. One of the fields in the user structure was u_error. So functions returned an error by setting u.u_error. If the kernel needed to do an internal I/O operation (say read the contents of a directory block to find an entry), it would need to save u.u_error, do the I/O, check u.u_error to find out if it succeeded, then restore u.u_error. Our goal was to get rid of the user structure. So we made a sweep over the entire kernel to get rid of uses of u.u_* accesses. For u.u_error we changed functions so that they always returned errors. Many of the fields that now appear in the uio structure were in the user area. So we gathered them together to define the uio structure and passed a pointer to a uio structure to functions that needed to use it. Finding out the current process was done using u.u_procp. We eliminated this by passing the process pointer in as one of the parameters to each system call. Once we moved to threads, the pointer to the process was changed to be a pointer to the thread. Most of these changes were correct and carry over nicely to today. In retrospect, the passing of the thread was not the right approach. It becomes a parameter to near every call and is often just a passthrough. So, if I had a time machine and could go back, I would have dropped the idea of passing the process pointer and just stuck with usng then curproc(), now curthread(). So, this is a long-winded way of saying that purging the passing of td seems like a reasonable idea though one has to ask if the cost in code churn is worth the effort. Kirk McKusick