Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1294620pxu; Thu, 17 Dec 2020 06:52:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbMWeDLusPwEg2sgdk4JFKjbALD80a9XhtnPDC8CJ0ZywiYYFfkCw7npFvCEUmOLZ6ezLq X-Received: by 2002:a17:906:3b55:: with SMTP id h21mr35505769ejf.184.1608216736842; Thu, 17 Dec 2020 06:52:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608216736; cv=none; d=google.com; s=arc-20160816; b=OBTUkDP3v1oUwwp1Emq3UkLAve1grUq6aFFwRv60UUUCBRXKtaZhc7VPGoPp+a3m6o VuZ1YptZBTvb3idqi8A2FEaTA+5Wy8KCtrifADCmbheFYoHt6AEL+ujXG3mqsDcV1nFL 3J2f9w1ZmSuiKEblX8cwLmDvz8uGgzeeipBFkVYAM+LaNw6agQggl/WrkfEzLdWUgVsk v1w+iE/cE+fMA9BMVIUeGRRRD8SmitIt8RCXRJFKImtsYX+swmud4O2YAiNrprBomdks ewRGWcVimNCvXOUhZoxQUAl4b/c9Y13ZmF4SlX6xZr8RwQMXvmakAmW66aBGI/wa1VeK btrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=YogHC27dUfdxMyB22ud/NJqrAhXEpWbGzc1AtvrRMlw=; b=nHMhzhHAiWXfAPaldcSXY/jetpJBtA5Kku2wE9ugl/jIo6rgkHz3mLqcNWI4rDTIa0 xaBKQKnCwYYNUdk+wfYCtpsHKPuIkC6uu0JEX5uNmqGaEzVdnLaWB9sWlfP8jqROk9kf O2MGPPnk7wOGCWjIIL6yPKWpivBkCA9UfWlvbB4M1y3d40XDoUpoDdwG7kkPeOGMKBoG /HPW9d19q+dzV8iLgwq3SwUWX21MRjf4Mhffgjo80dAqWxvNR2Vvbg6QIz79eBHSXsfm iUc01PJNnApWTkiTVv8yPoDqF+t9j6Qf+hvRwFrND9QhA+fROel8FBVRsLrwaGKxCWD5 8f0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=PHV83dha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si2669391eja.494.2020.12.17.06.51.51; Thu, 17 Dec 2020 06:52:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=PHV83dha; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbgLQOvY (ORCPT + 99 others); Thu, 17 Dec 2020 09:51:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:34590 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbgLQOvX (ORCPT ); Thu, 17 Dec 2020 09:51:23 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1608216636; h=from:from:reply-to: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=YogHC27dUfdxMyB22ud/NJqrAhXEpWbGzc1AtvrRMlw=; b=PHV83dhaP+aTMkKJl0013KHSZ71xxPmZwkeT7qualG09NoQLG7Qmiqqjq0RXYcn1OKC4eq dEZdO1vhDnMsZ17m2cQepTmw9K06IGMxWY2/QF3mYRRiO7K0TEONCxAURVHQONOekwqCut NhkWXH4cdJYhx02TyriUichjjkjK4jQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EE897AE91; Thu, 17 Dec 2020 14:50:35 +0000 (UTC) Subject: Re: [PATCH 4/5] xen/xenbus: Count pending messages for each watch To: SeongJae Park , stable@vger.kernel.org Cc: SeongJae Park , doebel@amazon.de, aams@amazon.de, mku@amazon.de, julien@xen.org, wipawel@amazon.de, linux-kernel@vger.kernel.org, Author Redacted References: <20201217081727.8253-1-sjpark@amazon.com> <20201217081727.8253-5-sjpark@amazon.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <76711b5d-4166-19ff-e817-694675051f90@suse.com> Date: Thu, 17 Dec 2020 15:50:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201217081727.8253-5-sjpark@amazon.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BTFEMFwHXxBd5wmigQYtzuEXr1td99gpv" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BTFEMFwHXxBd5wmigQYtzuEXr1td99gpv Content-Type: multipart/mixed; boundary="SQpQFETUAy8uNs8fWFqgHqcxQAkJt9N2F"; protected-headers="v1" From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= To: SeongJae Park , stable@vger.kernel.org Cc: SeongJae Park , doebel@amazon.de, aams@amazon.de, mku@amazon.de, julien@xen.org, wipawel@amazon.de, linux-kernel@vger.kernel.org, Author Redacted Message-ID: <76711b5d-4166-19ff-e817-694675051f90@suse.com> Subject: Re: [PATCH 4/5] xen/xenbus: Count pending messages for each watch References: <20201217081727.8253-1-sjpark@amazon.com> <20201217081727.8253-5-sjpark@amazon.com> In-Reply-To: <20201217081727.8253-5-sjpark@amazon.com> --SQpQFETUAy8uNs8fWFqgHqcxQAkJt9N2F Content-Type: multipart/mixed; boundary="------------CA64A13DB928E42B8023DDC0" Content-Language: en-US This is a multi-part message in MIME format. --------------CA64A13DB928E42B8023DDC0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 17.12.20 09:17, SeongJae Park wrote: > From: SeongJae Park >=20 > This commit adds a counter of pending messages for each watch in the > struct. It is used to skip unnecessary pending messages lookup in > 'unregister_xenbus_watch()'. It could also be used in 'will_handle' > callback. >=20 > This is part of XSA-349 >=20 > This is upstream commit 3dc86ca6b4c8cfcba9da7996189d1b5a358a94fc >=20 > Cc: stable@vger.kernel.org > Signed-off-by: SeongJae Park > Reported-by: Michael Kurth > Reported-by: Pawel Wieczorkiewicz > Signed-off-by: Author Redacted > Reviewed-by: Juergen Gross > Signed-off-by: Juergen Gross > --- > drivers/xen/xenbus/xenbus_xs.c | 30 ++++++++++++++++++------------ > include/xen/xenbus.h | 2 ++ > 2 files changed, 20 insertions(+), 12 deletions(-) >=20 > diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus= _xs.c > index 0ea1c259f2f1..420d478e1708 100644 > --- a/drivers/xen/xenbus/xenbus_xs.c > +++ b/drivers/xen/xenbus/xenbus_xs.c > @@ -701,6 +701,8 @@ int register_xenbus_watch(struct xenbus_watch *watc= h) > =20 > sprintf(token, "%lX", (long)watch); > =20 > + watch->nr_pending =3D 0; > + I'm missing the incrementing of nr_pending, which was present in the upstream patch. Juergen > down_read(&xs_state.watch_mutex); > =20 > spin_lock(&watches_lock); > @@ -750,12 +752,15 @@ void unregister_xenbus_watch(struct xenbus_watch = *watch) > =20 > /* Cancel pending watch events. */ > spin_lock(&watch_events_lock); > - list_for_each_entry_safe(msg, tmp, &watch_events, list) { > - if (msg->u.watch.handle !=3D watch) > - continue; > - list_del(&msg->list); > - kfree(msg->u.watch.vec); > - kfree(msg); > + if (watch->nr_pending) { > + list_for_each_entry_safe(msg, tmp, &watch_events, list) { > + if (msg->u.watch.handle !=3D watch) > + continue; > + list_del(&msg->list); > + kfree(msg->u.watch.vec); > + kfree(msg); > + } > + watch->nr_pending =3D 0; > } > spin_unlock(&watch_events_lock); > =20 > @@ -802,7 +807,6 @@ void xs_suspend_cancel(void) > =20 > static int xenwatch_thread(void *unused) > { > - struct list_head *ent; > struct xs_stored_msg *msg; > =20 > for (;;) { > @@ -815,13 +819,15 @@ static int xenwatch_thread(void *unused) > mutex_lock(&xenwatch_mutex); > =20 > spin_lock(&watch_events_lock); > - ent =3D watch_events.next; > - if (ent !=3D &watch_events) > - list_del(ent); > + msg =3D list_first_entry_or_null(&watch_events, > + struct xs_stored_msg, list); > + if (msg) { > + list_del(&msg->list); > + msg->u.watch.handle->nr_pending--; > + } > spin_unlock(&watch_events_lock); > =20 > - if (ent !=3D &watch_events) { > - msg =3D list_entry(ent, struct xs_stored_msg, list); > + if (msg) { > msg->u.watch.handle->callback( > msg->u.watch.handle, > (const char **)msg->u.watch.vec, > diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h > index 1772507dc2c9..ed9e7e3307b7 100644 > --- a/include/xen/xenbus.h > +++ b/include/xen/xenbus.h > @@ -58,6 +58,8 @@ struct xenbus_watch > /* Path being watched. */ > const char *node; > =20 > + unsigned int nr_pending; > + > /* > * Called just before enqueing new event while a spinlock is held. > * The event will be discarded if this callback returns false. >=20 --------------CA64A13DB928E42B8023DDC0 Content-Type: application/pgp-keys; name="OpenPGP_0xB0DE9DD628BF132F.asc" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="OpenPGP_0xB0DE9DD628BF132F.asc" -----BEGIN PGP PUBLIC KEY BLOCK----- xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy= cWx w3ie3j9uvg9EOB3aN4x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oN1EblHI//x/e2AaIHpzK5h88N= Eaw QsaNRpNSrcfbFmAg987ATQRTjHAWAQgAyzH6AOODMBjgfWE9VeCgsrwH3exNAU32gLq2xvjpW= nHI s98ndPUDpnoxWQugJ6MpMncr0xSwFmHEgnSEjK/PAjppgmyc57BwKII3sV4on+gDVFJR6Y8ZR= wgn BC5mVM6JjQ5xDk8WRXljExRfUX9pNhdE5eBOZJrDRoLUmmjDtKzWaDhIg/+1Hzz93X4fCQkNV= bVF LELU9bMaLPBG/x5q4iYZ2k2ex6d47YE1ZFdMm6YBYMOljGkZKwYde5ldM9mo45mmwe0icXKLk= pEd IXKTZeKDO+Hdv1aqFuAcccTg9RXDQjmwhC3yEmrmcfl0+rPghO0Iv3OOImwTEe4co3c1mwARA= QAB wsBfBBgBAgAJBQJTjHAWAhsMAAoJELDendYovxMvQ/gH/1ha96vm4P/L+bQpJwrZ/dneZcmEw= Tbe 8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1= vJz Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8= VGi wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW= svi uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX= zXs ZDn8R38=3D =3D2wuH -----END PGP PUBLIC KEY BLOCK----- --------------CA64A13DB928E42B8023DDC0-- --SQpQFETUAy8uNs8fWFqgHqcxQAkJt9N2F-- --BTFEMFwHXxBd5wmigQYtzuEXr1td99gpv Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAl/bcDsFAwAAAAAACgkQsN6d1ii/Ey+s bwgAhqfxReFrMWGCDysNruAEcZR/t8BjDsh/rTAdFEaFG9b4JmLLsEt/85UoiFenooU7jAFdL+AK dv/RnWhMD+iFUNDGDIYPHejGPoBw3H7+EBVdSt9p4+d4WhIS+AlEQq7960KhNFVsP58jn4m2Elv9 hC08kBoRgffQFE2YZb5pztCWgHyh9KTP9LBEFwebmzCp1/rNSb5AOT+Yh8wkQIGP2Y+IYFgOaGcM KnAXnuax+41/FP6ZZMCQ0peGpLCJcXKGNFzyi9LlvPscVSAGh5ufNBepRupSFv3dg/oTORz7F84j LjeGBlzwrooIYcw63agNCJEcND2wlSKIcddRWhMvlQ== =0c7Y -----END PGP SIGNATURE----- --BTFEMFwHXxBd5wmigQYtzuEXr1td99gpv--