From: "Jan Beulich" Subject: Re: [PATCH] Avoid panic when adjusting sedf parameters Date: Thu, 17 Nov 2011 13:30:37 +0000 Message-ID: <4EC51A8D0200007800061933@nat28.tlf.novell.com> References: <8eea2b53adb207b8ab92.1321535022@nehalem1> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <8eea2b53adb207b8ab92.1321535022@nehalem1> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Juergen Gross Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org >>> On 17.11.11 at 14:03, Juergen Gross = wrote: >--- a/xen/include/xen/sched.h Wed Nov 16 18:21:14 2011 +0000 >+++ b/xen/include/xen/sched.h Thu Nov 17 14:01:58 2011 +0100 >@@ -569,6 +569,12 @@ extern struct domain *domain_list; > (_d) !=3D NULL; \ > (_d) =3D rcu_dereference((_d)->next_in_list )) \ >=20 >+#define for_each_domain_in_cpupool(_d,_c) \ >+ for ( (_d) =3D rcu_dereference(domain_list); \ >+ (_d) !=3D NULL; \ >+ (_d) =3D rcu_dereference((_d)->next_in_list )) \ Wouldn't this, up to here, simply be for_each_domain()? >+ if ((_d)->cpupool =3D=3D (_c)) This is dangerous - consider code like if ( x ) for_each_domain_in_cpupool () function(); else other_stuff; which would now associate the else with the wrong (inner) if. One possible solution that comes to mind would be #define for_each_domain_in_cpupool(_d,_c) \ for_each_domain_in_cpupool (_d) \ if ((_d)->cpupool !=3D (_c)) \ continue; \ else but I think I had seen a more clever solution to this problem, but cannot remember/locate it right now. Jan >+ > #define for_each_vcpu(_d,_v) \ > for ( (_v) =3D (_d)->vcpu ? (_d)->vcpu[0] : NULL; \ > (_v) !=3D NULL; \