From owner-freebsd-current@freebsd.org Thu Apr 11 01:24:08 2019 Return-Path: Delivered-To: freebsd-current@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 9A93915737B9 for ; Thu, 11 Apr 2019 01:24:08 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from CAN01-TO1-obe.outbound.protection.outlook.com (mail-eopbgr670054.outbound.protection.outlook.com [40.107.67.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "GlobalSign Organization Validation CA - SHA256 - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 843446E05A; Thu, 11 Apr 2019 01:24:05 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from QB1PR01MB3537.CANPRD01.PROD.OUTLOOK.COM (52.132.84.84) by QB1PR01MB3987.CANPRD01.PROD.OUTLOOK.COM (52.132.84.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.15; Thu, 11 Apr 2019 01:24:03 +0000 Received: from QB1PR01MB3537.CANPRD01.PROD.OUTLOOK.COM ([fe80::9c13:e118:131c:f3fd]) by QB1PR01MB3537.CANPRD01.PROD.OUTLOOK.COM ([fe80::9c13:e118:131c:f3fd%2]) with mapi id 15.20.1792.009; Thu, 11 Apr 2019 01:24:03 +0000 From: Rick Macklem To: Mateusz Guzik CC: "kib@freebsd.org" , "freebsd-current@FreeBSD.org" Subject: Do the pidhashtbl_locks added by r340742 need to be sx locks? Thread-Topic: Do the pidhashtbl_locks added by r340742 need to be sx locks? Thread-Index: AQHU8AP7fWJXG48RU0WTxwDO79KhQw== Date: Thu, 11 Apr 2019 01:24:03 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e5a506d9-4f9b-48f4-ebc5-08d6be1c6267 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(2017052603328)(7193020); SRVR:QB1PR01MB3987; x-ms-traffictypediagnostic: QB1PR01MB3987: x-microsoft-antispam-prvs: x-forefront-prvs: 00046D390F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(39860400002)(376002)(396003)(189003)(199004)(6436002)(450100002)(52536014)(53936002)(4326008)(5660300002)(9686003)(25786009)(2906002)(256004)(786003)(54906003)(316002)(14444005)(55016002)(99286004)(74482002)(86362001)(6916009)(186003)(97736004)(105586002)(6506007)(81156014)(102836004)(476003)(68736007)(8936002)(81166006)(106356001)(7696005)(8676002)(74316002)(33656002)(305945005)(486006)(478600001)(14454004)(71190400001)(71200400001)(46003); DIR:OUT; SFP:1101; SCL:1; SRVR:QB1PR01MB3987; H:QB1PR01MB3537.CANPRD01.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: uoguelph.ca does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: EIHmTzOEQohohEESDS9dMFbbTKh9XcIea41kVDE4xpOQ+qEhuHRBBtw4DEZr0c4y7ZD+lNCzmpNqDaIMY4fmOOcFhqygeS+dkngliiVtUk5ehDc3Smm+qHpr5EUphmR3hb+s4i81N/BM6/0hyfYuWJZCxWlUsdngXHHuP55Zd3mCZvMsSVBw/4KXkNU1uvGxB1lbjKAVfNQb+MkjT1BW4vQhubm6n9JRvwAegbg9h3PvHWnODyf94d+okcK3JJJ4p3heGf1LUvD3X5b2VJWgpIXW29h9TFgCU4ro+3ZQ8KfnGvY8IiKEKSTMn1eXf6jkTp59EtP6+x9xEkxRsouJTEWbc9flM0o8A4EMHbiZ7gJxTaa/jiQ1n1kkq6yic/XdWWUmF2bgNwlYzuoPX8lPnymbdH51QvSqqx8gIHlZj38= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: uoguelph.ca X-MS-Exchange-CrossTenant-Network-Message-Id: e5a506d9-4f9b-48f4-ebc5-08d6be1c6267 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Apr 2019 01:24:03.7382 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: be62a12b-2cad-49a1-a5fa-85f4f3156a7d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: QB1PR01MB3987 X-Rspamd-Queue-Id: 843446E05A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of rmacklem@uoguelph.ca designates 40.107.67.54 as permitted sender) smtp.mailfrom=rmacklem@uoguelph.ca X-Spamd-Result: default: False [-2.99 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+ip4:40.107.0.0/16]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[uoguelph.ca]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-0.98)[ipnet: 40.64.0.0/10(-2.61), asn: 8075(-2.23), country: US(-0.06)]; MX_GOOD(-0.01)[mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com,mx2.hc184-76.ca.iphmx.com,mx1.hc184-76.ca.iphmx.com]; NEURAL_HAM_SHORT(-0.70)[-0.702,0]; RCVD_IN_DNSWL_NONE(0.00)[54.67.107.40.list.dnswl.org : 127.0.3.0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:8075, ipnet:40.64.0.0/10, country:US]; MIME_TRACE(0.00)[0:+] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Apr 2019 01:24:08 -0000 Hi, I finally got around to looking at what effect replacing pfind_locked() wit= h pfind() has for the NFSv4 client and it is broken. The problem is that the NFS code needs to call some variant of "pfind()" wh= ile holding a mutex lock. The current _pfind() code uses the pidhashtbl_locks, which are "sx" locks. There are a few ways to fix this: 1 - Create a custom version of _pfind() for the NFS client with the sx_X() = calls removed, plus replace the locking of allproc_lock with locking of all= the pidhashtbl_locks, so that the "sx" locks are acquired before the mute= x. --> Not very efficient, but since it is only done once/sec, I can liv= e with it. 2 - Similar to the above, but still lock the allproc_lock and use a loop of FOREACH_PROC_IN_SYSTEM(p) instead of a hash list for the pid in the custom pfind(). (I don't know if this would be preferable to locking a= ll the pidhashtbl_locks for other users of pfind()?) 3 - Convert the pidhashtbl_locks to mutexes. Then the NFS client doesn't ne= ed to acquire any proc related locks and it just works. I can't see anywhere that "sleeps" while holding the pidhashtbl_locks,= so I think they can be converted, although I haven't tried it yet? >From my perspective, #3 seems the better solution. What do others think? rick