From nobody Fri May 23 06:44:27 2025 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4b3bHb20v7z5wrVd for ; Fri, 23 May 2025 06:44:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4b3bHZ1ZMMz3cmk; Fri, 23 May 2025 06:44:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 54N6iSSc007426; Fri, 23 May 2025 09:44:31 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 54N6iSSc007426 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 54N6iR9F007425; Fri, 23 May 2025 09:44:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 23 May 2025 09:44:27 +0300 From: Konstantin Belousov To: Brooks Davis Cc: Warner Losh , freebsd-current@freebsd.org Subject: Re: Un-sucking EINVAL Message-ID: References: <202505210722.54L7MTqw025632@critter.freebsd.dk> List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Rspamd-Queue-Id: 4b3bHZ1ZMMz3cmk X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Spamd-Bar: ---- On Thu, May 22, 2025 at 03:59:14PM +0000, Brooks Davis wrote: > On Thu, May 22, 2025 at 08:04:19AM +0300, Konstantin Belousov wrote: > > On Wed, May 21, 2025 at 11:23:12PM +0000, Brooks Davis wrote: > > > On Wed, May 21, 2025 at 11:07:09AM -0600, Warner Losh wrote: > > > > In short, I'd love to widen the interface, but there's a number of practical > > > > issues in the way. > > > > > > I think caching something in the kernel of later retrieval or adding a > > > new return path to the ABI is the wrong way around. Instead I think the > > > right solution is for each thread to register a userspace buffer. You > > > end up adding one or two entries to struct thread (pointer to a > > > structure or pointer to an buffer and length) and if the pointer is > > > non-NULL you copyout a string to the buffer. This avoids signficant > > > new storage in the kernel and means programs that won't use this data > > > don't see it. It also means that the debugger can access it without > > > needing a new PT_ argument. > > > > > > As a minor downside you would introduce some new error conditions if the > > > programmer messes up registration, but we'd probably just have libthr do > > > it in most cases (that would be more debugger friendly since you > > > could hang it off a known location in userspace). > > > > I mostly agree with this proposal, and can implement it. > > I strongly object against blowing the kernel with MBs of strings. > > > > Userspace can register per-thread extended errno location, and kernel > > can copyout the ext-errno when returning error. > > I really want them to be strings in the kernel. Anything else is too > annoying to maintain and will interact poorly with running old versions > of userspace and introduce namespace complications for downstreams. > > If you want the option to save the space, make the interface that copies > the string out a macro and provide an option to compile them away. > (Using a macro would also allow you to transparently embed e.g., file, > function, or line information if desired.) D50483 Extended errors from kernel