From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796168789; b=dWiBbXtFteU6+fpZvxg1afqs3ppPRn5QnZZoy+fE2svIsmR27qIZRjC0+KYD6C3228WJ QZKZGdHWu3AJFF6Pz+pG41EG2T89+HhhzB9cMN3xTAYzLJyu9C2ab/fr2HNbDlaWDLB+w LtPtrR+clTNJP5C6/XUnSCRqLsp3cbDj95UVO7ZOdOgFhyTFIblJUzHLh+BFlGaYhri9i xSk9NXJq2kGkwCyeKPZcotFT/Vz08QM2C/FYpANXZu9cSqWM8QTs0MNfrEI0HqXPwtRhC n5G3KTVLBTks98dWJ5SpPmnjuS7HVCjmwTkEtM1isceOMRqPuMs7YO+X2lbEtgPwhog== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796168789; h=DMARC-Filter:DKIM-Signature:X-MC-Rep:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Received:Received:Date:From: To:Cc:Subject:Message-ID:References:MIME-Version:In-Reply-To: X-Scanned-By:X-Mimecast-Spam-Score:X-Mimecast-MFC-PROC-ID: X-Mimecast-Originator:Content-Type:Content-Disposition; bh=fDDYE0OrAjYGYzWeCRitK6OKkMLQTipMf0BWk6KuDUs=; b=wOATA9a1aJRf9HYUKt2gIJ6Tlz7Pw46ViqfSx9MG0Gs7uN4dMQvrfWZClBlup6PTl5oU kO6GP9jdmPddvUWq07rKSCxwDegAX6Am+BMm4be4wR1UZ/PpCbOklxNf9D8lE8adh3XFu m2PwyGvn3ZE95oX1RBQzwohOYVH1BUy6FdrZSDIMMImX0T/YIyRZv9iWCITfIFt078Crv 0zoGErjyKrTxyxm81j0V7E757OtD+FU0zjMVY+rimlF4dbpS9Nx9PXr+VUOYbtJWZa2cm gRU2wkA63031+85aYHxCLZvI7wytxxxpIS3yBV/KljB15Sauy4eAOJsfYM6u5AWa3pA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LBp2ShrN; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF55D606A31A for ; Tue, 1 Dec 2026 23:46:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CF55D606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LBp2ShrN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796168787; 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=fDDYE0OrAjYGYzWeCRitK6OKkMLQTipMf0BWk6KuDUs=; b=LBp2ShrN1naixsEI5Uu33R8AH/3iK+ifM1l9EWyY50HT1lClK2HNLsDsTDAX8MXB/4aDH5 3CE7YDnydgXrwT9qYSCkWKPQQWmEVMxcTor3tljUqM/Z6VHhPrIFtXGyJZky9j+DR4jbMn VCd+cPCbftJwJvS5lhBsTWK2mM4N0pE= X-MC-Rep: binary re single Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-NP-nS7EiMwu9Br2WUpWJrw-1; Tue, 1 Dec 2026 23:46:24 +0000 X-MC-Unique: NP-nS7EiMwu9Br2WUpWJrw-1 X-Mimecast-MFC-AGG-ID: NP-nS7EiMwu9Br2WUpWJrw_1796168783 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 124E3192C581; Tue, 1 Dec 2026 23:46:23 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (bmarzins-01.fast.eng.rdu2.dc.redhat.com [10.6.23.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A6BBB195421A; Tue, 1 Dec 2026 23:46:22 +0000 (UTC) Received: from bmarzins-01.fast.eng.rdu2.dc.redhat.com (localhost [127.0.0.1]) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.18.1/8.17.1) with ESMTPS id 6B1NkLeU084093 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 1 Dec 2026 18:46:21 -0500 Received: (from bmarzins@localhost) by bmarzins-01.fast.eng.rdu2.dc.redhat.com (8.18.1/8.18.1/Submit) id 6B1NkIWV084071; Tue, 1 Dec 2026 18:46:18 -0500 Date: Tue, 1 Dec 2026 18:46:18 -0500 From: Benjamin Marzinski To: Martin Wilck Cc: Christophe Varoqui , device-mapper development Subject: Re: [PATCH 2/4] multipathd: add infrastructure for uxlsnr waiting on events Message-ID: References: <20261126052434.725762-1-bmarzins@redhat.com> <20261126052434.725762-3-bmarzins@redhat.com> <179569332052.310906.11503714620320054070.b4-review@b4> X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HgMW6f2sCMswbI6ZPlbEPyVpxiFX80XTEsExTIsqTKA_1796168783 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 30, 2026 at 11:55:04AM -0500, Benjamin Marzinski wrote: > On Thu, Nov 26, 2026 at 12:42:00PM +0100, Martin Wilck wrote: > > > +/* must only be called by uxlsnr_thr */ > > > +static void stop_waiting_for_event(struct client *c) > > > +{ > > > + /* > > > + * As long as clients will only be added to wait lists by uxlsnr_thr > > > + * and only removed with list_del_init(), it is safe to check if > > > + * wait_node is empty without holding client_wait_lock. uxlsnr_thr > > > + * can't miss a client being added to the list, since a process is > > > + * guaranteed to see all memory changes it did. It can miss a client > > > + * being removed from the list or see a torn write from a concurrent > > > + * removal, but this will just cause it to unnecessarily grab the lock > > > + * and redo the removal. > > > + */ > > > + if (!list_empty(&c->wait_node)) { > > > > Tbh, I don't like this super-smart optimization. I would prefer just taking > > the lock. If we find this to hurt performance, we could change the > > implementation to RCU. > > It just seems wrong to grab the lock every time any client exits. Would > you be o.k. with having a special return value from the client handler > functions to signal that the client needs to wait and a flag that > clients can set when they get this return? Clients who haven't set the > flag can skip the lock, just like with the current list empty code. Only > the uxlsnr thread would set and check the flag, so there's no locking > needed. O.k. so that specific idea won't work. If the uxlsnr thread gets cancelled between when the wait_node got added to the list and when the cli_handler returned, the flag wouldn't be set and thus dead_client() wouldn't remove the client from the wait list. That opens a small window where another thread could be accessing the freed memory while calling wakeup_event_waiter(). Instead, I could just set the flag directly when the client's wait_node is added to the list in wait_for_event(). The rest of the argument is the same. -Ben