From nobody Sat Sep 23 16:32:34 2023 X-Original-To: dev-commits-src-all@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 4RtF6j3kG6z4tvXN; Sat, 23 Sep 2023 16:32:45 +0000 (UTC) (envelope-from zlei@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RtF6j3X15z4Wls; Sat, 23 Sep 2023 16:32:45 +0000 (UTC) (envelope-from zlei@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695486765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QbQ9eMqelFXPPfqKQjRHK6Bz8v6VNxeZIBDtRp69Kt4=; b=lJ9K3ZibKrZhyW6jFfbtqyBHyKDWatxLrxobasFk9TKWMYJRztAP8trauNExhQsC43fbMX S8hd1pYVfH3Dj9Wn7xzUhDPh4Rtbd2GOzyfcXue1N+D1T7sY4rdopvYaSoFq8tUC4szYl2 tyXBg/F/+MA52nSXv9FH3aO3zgJsr8828MmkzRd1yckOOuAR52ndd10rUzKBHp4FmLL7vE rsyz5ihCNEpcxPWbhe4pqfRqEASL3PuOcshBMI6XvsVoy9XLhHfv8yXpwauzvmccewGMEJ BFn/tE+UILdPO6KCR5XVYO+JPII6OqUN9Xr742atXIgRX+xnXbCbYJdicvPe5w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695486765; a=rsa-sha256; cv=none; b=lwMg2PBzbcwSpEE1ulDnMYd1jt/WC4OFr/6wo80M7VFuH8nB/pSWq1XDdh6jN7ozz26WuO mU03PjLf19pAJVK/cFnVFdb2zjNmj3iMxrCE7W/JmvUCzkqw6d0DPm/wFx3aOVXuKAnwXp ryPkIglC1xBPbgTCDPmDoZ5MIdZ+9uqliJazXgARGsdz5gCgilIAPr2MLJsXQ5rYSLhAZf ZoyQBNw7Og6dHLTaNJDyBaH4c969vZIb3nRe06/KVXuCQuKzVix3teAnBq+QxyAuy19SGD Apicr+hzpvXi0j9UFC0fPB07mh7i1ey5pHkJwpGq/gaKuOkbC/slSl7vpbyXJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695486765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QbQ9eMqelFXPPfqKQjRHK6Bz8v6VNxeZIBDtRp69Kt4=; b=xp48gb9vxVfsY11Wn2b3hfiRcs7Yz1N3mTfJj+KNK31ihrKl7dMZSIQgFZatuAaoBBL5G7 nTb27mSNLEAskzbsceIOXfCt9a2Jq1EmZ036lS+n9HyWgce6+3NUUsZMU2fkhF3xhyDoFA Q2qYSoOR0A6lHQHNBeZgXbj0uGyCEHam1I2VWA2Cul13YfekA7o52zjcA/HG9Fuh0vSFHv 1XEM1IG5F7d7iXIPTDycgIa7KWihbnLXj/Z2BFm0AdnOOarS1eFANz4L36/sRaBQRhh2V/ X+xYNWrT0noZNejBOhB6PHlWeYoOGRP8Sk0yjRC3JBZbfMrYHF8Wpwc0wuAceQ== Received: from smtpclient.apple (ns1.oxydns.net [45.32.91.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: zlei/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RtF6g2JQcz1NHZ; Sat, 23 Sep 2023 16:32:42 +0000 (UTC) (envelope-from zlei@FreeBSD.org) From: Zhenlei Huang Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_E160494E-9351-4B11-92D7-7DC5AA6B3BB3" List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: git: cf7974fd9e55 - main - sysctl: Update 'master' copy of vnet SYSCTLs on kernel environment variables change Date: Sun, 24 Sep 2023 00:32:34 +0800 In-Reply-To: <15442125-499F-44FD-924A-472CE0709001@FreeBSD.org> Cc: src-committers@freebsd.org, dev-commits-src-main@freebsd.org, dev-commits-src-all@freebsd.org To: Peter Holm References: <202309210413.38L4D42w076513@gitrepo.freebsd.org> <649B777A-CA29-42B7-AF92-DE8AF664D5CB@FreeBSD.org> <800CB4EC-7AAF-4825-8146-47FBA94FEFAE@FreeBSD.org> <15442125-499F-44FD-924A-472CE0709001@FreeBSD.org> X-Mailer: Apple Mail (2.3696.120.41.1.4) --Apple-Mail=_E160494E-9351-4B11-92D7-7DC5AA6B3BB3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Sep 22, 2023, at 12:59 AM, Zhenlei Huang wrote: >=20 >=20 >=20 >> On Sep 22, 2023, at 12:39 AM, Peter Holm > wrote: >>=20 >> On Thu, Sep 21, 2023 at 11:35:49PM +0800, Zhenlei Huang wrote: >>>=20 >>>=20 >>>> On Sep 21, 2023, at 11:23 PM, Peter Holm > wrote: >>>>=20 >>>> On Thu, Sep 21, 2023 at 10:45:20PM +0800, Zhenlei Huang wrote: >>>>>=20 >>>>>=20 >>>>>> On Sep 21, 2023, at 5:55 PM, Peter Holm > wrote: >>>>>>=20 >>>>>> On Thu, Sep 21, 2023 at 04:05:19PM +0800, Zhenlei Huang wrote: >>>>>>>=20 >>>>>>>=20 >>>>>>>> On Sep 21, 2023, at 2:07 PM, Peter Holm > wrote: >>>>>>>>=20 >>>>>>>> On Thu, Sep 21, 2023 at 04:13:04AM +0000, Zhenlei Huang wrote: >>>>>>>>> The branch main has been updated by zlei: >>>>>>>>>=20 >>>>>>>>> URL: = https://cgit.FreeBSD.org/src/commit/?id=3Dcf7974fd9e554552989237c3d6bc736d= 672ac7c6 = >>>>>>>>>=20 >>>>>>>>> commit cf7974fd9e554552989237c3d6bc736d672ac7c6 >>>>>>>>> Author: Zhenlei Huang > >>>>>>>>> AuthorDate: 2023-09-21 04:11:28 +0000 >>>>>>>>> Commit: Zhenlei Huang > >>>>>>>>> CommitDate: 2023-09-21 04:11:28 +0000 >>>>>>>>>=20 >>>>>>>>> sysctl: Update 'master' copy of vnet SYSCTLs on kernel = environment variables change >>>>>>>>>=20 >>>>>>>>> Complete phase three of 3da1cf1e88f8. >>>>>>>>>=20 >>>>>>>>> With commit 110113bc086f, vnet sysctl variables can be loader = tunable >>>>>>>>> but the feature is limited. When the kernel modules have been = initialized, >>>>>>>>> any changes (e.g. via kenv) to kernel environment variable = will not affect >>>>>>>>> subsequently created VNETs. >>>>>>>>>=20 >>>>>>>>> This change relexes the limitation by listening on kernel = environment >>>>>>>>> variable's set / unset events, and then update the 'master' = copy of vnet >>>>>>>>> SYSCTL or restore it to its initial value. >>>>>>>>>=20 >>>>>>>>> With this change, TUNABLE_XXX_FETCH can be greately eliminated = for vnet >>>>>>>>> loader tunables. >>>>>>>>>=20 >>>>>>>>> Reviewed by: glebius >>>>>>>>> Fixes: 110113bc086f sysctl(9): Enable vnet sysctl variables = to be loader tunable >>>>>>>>> MFC after: 2 weeks >>>>>>>>> Differential Revision: https://reviews.freebsd.org/D41825 = >>>>>>>>=20 >>>>>>>> This commit seems to cause: >>>>>>>>=20 >>>>>>>> b> bt >>>>>>>> Tracing pid 0 tid 100000 td 0xffffffff8196ba00 >>>>>>>> kdb_enter() at kdb_enter+0x32/frame 0xffffffff821658e0 >>>>>>>> vpanic() at vpanic+0x163/frame 0xffffffff82165a10 >>>>>>>> panic() at panic+0x43/frame 0xffffffff82165a70 >>>>>>>> vm_fault() at vm_fault+0x18c9/frame 0xffffffff82165ba0 >>>>>>>> vm_fault_trap() at vm_fault_trap+0x6f/frame 0xffffffff82165be0 >>>>>>>> trap_pfault() at trap_pfault+0x24a/frame 0xffffffff82165c50 >>>>>>>> calltrap() at calltrap+0x8/frame 0xffffffff82165c50 >>>>>>>> --- trap 0xc, rip =3D 0xffffffff80c6f39b, rsp =3D = 0xffffffff82165d20, rbp =3D 0xffffffff82165d20 --- >>>>>>>> strsep() at strsep+0x3b/frame 0xffffffff82165d20 >>>>>>>> name2oid() at name2oid+0x66/frame 0xffffffff82165d70 >>>>>>>> sysctl_setenv_vnet() at sysctl_setenv_vnet+0x38/frame = 0xffffffff82165e00 >>>>>>>> kern_setenv() at kern_setenv+0x324/frame 0xffffffff82165e40 >>>>>>>> nfs_setup_diskless() at nfs_setup_diskless+0x4b2/frame = 0xffffffff82165f90 >>>>>>>=20 >>>>>>> Is that a NFS diskless workstation ? >>>>>>>=20 >>>>>>=20 >>>>>> Yes, sort of. It's a host in the netperf cluster, which uses = pxeboot & >>>>>> NFS. >>>>>>=20 >>>>>> - Peter >>>>>>=20 >>>>>>> I have tested that yet. I'll look at that tonight (UTC+8) . >>>>>>>=20 >>>>>>=20 >>>>>> Let me know when you have a patch, so I can test it (if you = like). >>>>>=20 >>>>> I believe I've found the root cause. >>>>>=20 >>>>> strsep(char **stringp, const char *delim) have side effect, it = will modify (* stringp) . >>>>> If stringp is pointed to some const value, such as = "boot.netif.name" in 'sys/nfs/nfs_diskless.c', then >>>>> the kernel will panic. >>>>>=20 >>>>> I'm preparing the patch, I'll reply when it is done. >>>>>=20 >>>>=20 >>>> This is great news! >>>=20 >>> Can you please try the attached patch ? =20 >>>=20 >>=20 >> Yes, the patch works for me: >=20 > Excellent ! >=20 > I'm going to send the patch to Phabricator. Alexander Motin has just committed f80babf906b7 (kern_sysctl: Make = name2oid() non-destructive to the name), that should fix this issue perfectly ;) >=20 >>=20 >> root@mercat1:~ # uname -a >> FreeBSD mercat1.netperf.freebsd.org = 15.0-CURRENT FreeBSD 15.0-CURRENT = #0 main-n265437-cf7974fd9e5545-dirty: Thu Sep 21 18:26:45 CEST 2023 = pho@mercat1.netperf.freebsd.org = :/usr/src/sys/amd64/compile/PHO = amd64 >> root@mercat1:~ # cd /usr/src; git status | grep kern_sysctl.c >> modified: sys/kern/kern_sysctl.c >> root@mercat1:/usr/src #=20 >>=20 >> - Peter --Apple-Mail=_E160494E-9351-4B11-92D7-7DC5AA6B3BB3 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

On Sep 22, 2023, at 12:59 AM, Zhenlei Huang <zlei@FreeBSD.org> = wrote:



On= Sep 22, 2023, at 12:39 AM, Peter Holm <pho@FreeBSD.org> = wrote:

On Thu, Sep 21, 2023 at = 11:35:49PM +0800, Zhenlei Huang wrote:


On Sep 21, 2023, at 11:23 PM, Peter Holm <pho@freebsd.org> = wrote:

On Thu, Sep 21, 2023 at 10:45:20PM = +0800, Zhenlei Huang wrote:


On Sep 21, 2023, at 5:55 PM, Peter Holm <pho@freebsd.org> = wrote:

On Thu, Sep 21, 2023 at 04:05:19PM = +0800, Zhenlei Huang wrote:


On Sep 21, 2023, at 2:07 PM, Peter Holm <pho@FreeBSD.org> = wrote:

On Thu, Sep 21, 2023 at 04:13:04AM = +0000, Zhenlei Huang wrote:
The branch main has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=3Dcf7974fd9e55455298923= 7c3d6bc736d672ac7c6

commit = cf7974fd9e554552989237c3d6bc736d672ac7c6
Author: =     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-09-21 04:11:28 +0000
Commit: =     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-09-21 04:11:28 +0000

sysctl: Update 'master' copy of vnet SYSCTLs on kernel = environment variables change

Complete phase = three of 3da1cf1e88f8.

With commit = 110113bc086f, vnet sysctl variables can be loader tunable
but the feature is limited. When the kernel modules have been = initialized,
any changes (e.g. via kenv) to kernel = environment variable will not affect
subsequently created = VNETs.

This change relexes the limitation = by listening on kernel environment
variable's set / unset = events, and then update the 'master' copy of vnet
SYSCTL = or restore it to its initial value.

With = this change, TUNABLE_XXX_FETCH can be greately eliminated for vnet
loader tunables.

Reviewed by: =    glebius
Fixes:  110113bc086f = sysctl(9): Enable vnet sysctl variables to be loader tunable
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D41825

This commit seems to cause:

b> bt
Tracing pid 0 tid = 100000 td 0xffffffff8196ba00
kdb_enter() at = kdb_enter+0x32/frame 0xffffffff821658e0
vpanic() at = vpanic+0x163/frame 0xffffffff82165a10
panic() at = panic+0x43/frame 0xffffffff82165a70
vm_fault() at = vm_fault+0x18c9/frame 0xffffffff82165ba0
vm_fault_trap() = at vm_fault_trap+0x6f/frame 0xffffffff82165be0
trap_pfault()= at trap_pfault+0x24a/frame 0xffffffff82165c50
calltrap() = at calltrap+0x8/frame 0xffffffff82165c50
--- trap 0xc, rip = =3D 0xffffffff80c6f39b, rsp =3D 0xffffffff82165d20, rbp =3D = 0xffffffff82165d20 ---
strsep() at strsep+0x3b/frame = 0xffffffff82165d20
name2oid() at name2oid+0x66/frame = 0xffffffff82165d70
sysctl_setenv_vnet() at = sysctl_setenv_vnet+0x38/frame 0xffffffff82165e00
kern_setenv() at kern_setenv+0x324/frame = 0xffffffff82165e40
nfs_setup_diskless() at = nfs_setup_diskless+0x4b2/frame 0xffffffff82165f90

Is that a NFS diskless = workstation ?


Yes, sort of. It's a host in the netperf cluster, which uses = pxeboot &
NFS.

- Peter

I have = tested that yet. I'll look at that tonight (UTC+8) .


Let me know when you have a = patch, so I can test it (if you like).

I believe I've found the root cause.

strsep(char **stringp, const char *delim) have side effect, = it will modify (* stringp) .
If stringp is pointed to some = const value, such as "boot.netif.name" in 'sys/nfs/nfs_diskless.c', = then
the kernel will panic.

I'm= preparing the patch, I'll reply when it is done.


This is great news!

Can you please try the attached = patch ?  


Yes, the patch works for = me:

Excellent !

I'm = going to send the patch = to Phabricator.

Alexander Motin has just committed f80babf906b7 = (kern_sysctl: Make name2oid() non-destructive to the = name),
that should fix this issue perfectly ;)



root@mercat1:~ # uname -a
FreeBSD mercat1.netperf.freebsd.org 15.0-CURRENT FreeBSD = 15.0-CURRENT #0 main-n265437-cf7974fd9e5545-dirty: Thu Sep 21 18:26:45 = CEST 2023 pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO amd64
root@mercat1:~ # cd = /usr/src; git status | grep kern_sysctl.c
       modified: =   sys/kern/kern_sysctl.c
root@mercat1:/usr/src = # 

- = Peter


= --Apple-Mail=_E160494E-9351-4B11-92D7-7DC5AA6B3BB3--