From: "Jan Beulich" Subject: Re: [PATCH] Avoid panic when adjusting sedf parameters Date: Thu, 17 Nov 2011 14:29:09 +0000 Message-ID: <4EC528450200007800061980@nat28.tlf.novell.com> References: <4EC51A8D0200007800061933@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: 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: Keir Fraser , Juergen Gross Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org >>> On 17.11.11 at 14:52, Keir Fraser wrote: > On 17/11/2011 13:30, "Jan Beulich" wrote: >=20 >> which would now associate the else with the wrong (inner) if. One >> possible solution that comes to mind would be >>=20 >> #define for_each_domain_in_cpupool(_d,_c) \ >> for_each_domain_in_cpupool (_d) \ >> if ((_d)->cpupool !=3D (_c)) \ >> continue; \ >> else >>=20 >> but I think I had seen a more clever solution to this problem, but = cannot >> remember/locate it right now. >=20 > Given the gcc ({}) construction, you could do a double-loop: > for ( (_d) =3D rcu_dereference(domain_list); \ > (_d) !=3D NULL; \ > ({ while ((_d) =3D rcu_dereference((_d)->next_in_list !=3D NULL) > if ((_d)->cpupool =3D=3D (_c)) break; > (_d); }) ) >=20 > A bit ugly. ;-) And I still worry about cpupool locking... No - the very first domain would make into the body of the loop without its pool being checked. The (adjusted) construct would need to go into the checking (middle) portion of the for. Jan