From: "Jan Beulich" Subject: Re: [PATCH] Avoid panic when adjusting sedf parameters Date: Thu, 17 Nov 2011 14:32:13 +0000 Message-ID: <4EC528FD0200007800061983@nat28.tlf.novell.com> References: <4EC51489.4090609@ts.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4EC51489.4090609@ts.fujitsu.com> 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 15:04, Juergen Gross = wrote: > On 11/17/2011 02:52 PM, Keir Fraser wrote: >> On 17/11/2011 13:30, "Jan Beulich" wrote: >> >>> 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. >> 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); }) ) >> >> A bit ugly. ;-) And I still worry about cpupool locking... >=20 > What about: >=20 > static inline struct domain *next_domain_in_cpupool( > struct domain *d, struct cpupool *c) > { > for (d =3D rcu_dereference(d->next_in_list); d && d->cpupool !=3D = c; > d =3D rcu_dereference(d->next_in_list)); > return d; > } >=20 > #define for_each_domain_in_cpupool(_d,_c) \ > for ( (_d) =3D rcu_dereference(domain_list); \ > (_d) !=3D NULL; \ > (_d) =3D next_domain_in_cpupool((_d), (_c))) Same problem as with Keir's variant - you'd enter the loop body for the first domain on the list regardless of its cpupool. But with a first_domain_in_cpupool() counterpart this might be usable. Or, as said in the other reply, putting a more complex construct in the middle clause. Jan