Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD601C38A24 for ; Thu, 7 May 2020 16:40:05 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DEBF20838 for ; Thu, 7 May 2020 16:40:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DEBF20838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jWjYc-0003Jf-4L; Thu, 07 May 2020 16:39:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jWjYa-0003Ja-Nc for xen-devel@lists.xenproject.org; Thu, 07 May 2020 16:39:32 +0000 X-Inumbo-ID: 536933c6-9081-11ea-9f4d-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 536933c6-9081-11ea-9f4d-12813bfff9fa; Thu, 07 May 2020 16:39:31 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6D835B1AC; Thu, 7 May 2020 16:39:33 +0000 (UTC) Message-ID: Subject: Re: [PATCH] xen/sched: always modify vcpu pause flags atomically From: Dario Faggioli To: Juergen Gross , xen-devel@lists.xenproject.org Date: Thu, 07 May 2020 18:39:28 +0200 In-Reply-To: <20200506151655.26445-1-jgross@suse.com> References: <20200506151655.26445-1-jgross@suse.com> Organization: SUSE Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-28z0u6N0CAUKbwJByzYD" User-Agent: Evolution 3.36.2 MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: George Dunlap Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" --=-28z0u6N0CAUKbwJByzYD Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2020-05-06 at 17:16 +0200, Juergen Gross wrote: > credit2 is currently modifying the pause flags of vcpus non- > atomically > via sched_set_pause_flags() and sched_clear_pause_flags(). This is > dangerous as there are cases where the paus flags are modified > without > any lock held. >=20 Right. > So drop the non-atomic pause flag modification functions and rename > the > atomic ones dropping the _atomic suffix. >=20 > Fixes: a76255b4266516 ("xen/sched: make credit2 scheduler vcpu > agnostic.") > Signed-off-by: Juergen Gross > Reviewed-by: Dario Faggioli > --- > It should be noted that this issue wasn't introduced by core > scheduling > as even before credit2 was using the non-atomic __set_bit() and > __clear_bit() variants. > Yes. I can see that in 222234f2ad17185 ("xen: credit2: use non-atomic cpumask and bit operations"), where the svc->flags are switched to non- atomic updates (as, for them, it is true that they're always accessed while holding locks), switching of setting the _VPF_migrating pause->flags non atomically also slipped in, but that was clearly a mistake. :-( I believe (but I haven't checked this part too thoroughly) that it was the only one back then. Afterwords, when another instance was added, in __runq_tickle(), we found the already existing one and followed suit. Good catch, and thanks. :-) Regards --=20 Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <> (Raistlin Majere) --=-28z0u6N0CAUKbwJByzYD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEES5ssOj3Vhr0WPnOLFkJ4iaW4c+4FAl60OcAACgkQFkJ4iaW4 c+7zHhAArUenfxoCOwbGoMzRknFnF3qY9XIrCsSR5jH81/E+k6gx/OZ6wwA37M12 GD3DGdv32pEhZBzvhmQg5hAq/ux+6JdXGU6OlC8PYX77u4/AYFOj+ez3SXQhgoVF RJE+QTN3HGC1Zivdy13s0nNg6Sd9zRJ3mBcjGk8rTERMw30fizVsHZauLTUn5aII grj1jPtMxXfqQWhnwtbrrdymKZinAManFAkjcPK9ex5QTrQzr7e0rc/qXeUvDjtc mGj/T1tGgbSp4bVvuxgdZm5GkkCJUU36K4C1bNjTvScUah3kyOldEGSvI6vN2z9B h6DLnD9n4LRdYtvtqDKRNcRt8tFYgTiHesETPXWvSMgUgpAVLpbLgFBJiPPYh9GA hAyNVrUtzOCUL11WZ90Zr+CMaypS1mupqMEXhNoXnlmC9rnoGthvptidV+UM8Mzk Ad53iiTX8Hxzo8cKVgShD5Esq/0jaaaFKn49XjPaTNvZ7eV4/75YfJeDi3Db/tn6 V3Q2IuVfP8tAB8JsZW/FqEJluyo99dJNbxtEp4ZolSU+57uHUC98gsUcEZ8N8yYf urLjmUqhC2XYuBA3pb6sg2tvQxd6jXNToXP3AHfoGdTheGfu5wUtSSF5BSenQVmM hikYn77ipV7J87kT9/QYxdj1MYoOCUC9s3n/xFWHsI5Dr4hVzlM= =sweq -----END PGP SIGNATURE----- --=-28z0u6N0CAUKbwJByzYD--