From: Stefano Stabellini Subject: Re: Question, Lock of pending_irq struct in Xen ARM. Date: Mon, 9 Mar 2015 11:07:51 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="1342847746-277810854-1425899271=:9880" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: =?UTF-8?B?7Iug7KCV7ISt?= Cc: tim@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org --1342847746-277810854-1425899271=:9880 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 9 Mar 2015, =EC=8B=A0=EC=A0=95=EC=84=AD wrote: > HI. >=20 > I'm now modifying GIC in Xen 4.5.0.=C2=A0 >=20 > I have some question about lock of pending_irq struct in Xen ARM.=C2=A0 >=20 > =C2=A0 >=20 > pending_irq of SGI and PPI is stored in 'vcpu struct'. (IRQ num 0 ~ 31) >=20 > pending_irq of SPI is stored in 'domain struct'. (IRQ num 32 ~ ) >=20 > =C2=A0 >=20 > For accessing pending_irq struct, Xen use 'irq_to_pending(struct vcpu *v,= int =C2=A0irq)' function. >=20 > irq_to_pending function return proper=C2=A0pending_irq=C2=A0depending on = IRQ number.=C2=A0 >=20 > =C2=A0 >=20 > =C2=A0 >=20 > * 'gic_update_one_lr' function process >=20 > 1) before call=C2=A0gic_update_one_lr, xen acquire like this=C2=A0"spin_l= ock_irqsave(&v->arch.vgic.lock, flags)"; >=20 > 2) In=C2=A0gic_update_one_lr, get=C2=A0pending_irq through=C2=A0irq_to_pe= nding=C2=A0function. >=20 > 3) change state of=C2=A0irq_to_pending=C2=A0and update lr >=20 > =C2=A0 >=20 > When IRQ number is below 31,=C2=A0irq_to_pending=C2=A0function return pen= ding_irq stored in vcpu struct. >=20 > It's ok to change=C2=A0irq_to_pending=C2=A0state, because=C2=A0&v->arch.v= gic.lock acquire. >=20 > But When IRQ number is above 32,=C2=A0irq_to_pending=C2=A0function return= pending_irq stored in domain struct. >=20 > And change state of=C2=A0irq_to_pending=C2=A0without domain's lock. >=20 > I think that=C2=A0pending_irq of SPI stored in domain struct is shared am= ong vcpus. and need to acquire domain's lock=C2=A0before > change=C2=A0pending_irq. >=20 > But why don't use domain's lock in Xen Code ?? Thanks for the good analysis and the well framed question. It is safe to acquire just the vcpu lock, rather than the domain lock, because we always configure the system so that SPIs are delivered to just one physical cpu/one vcpu. It is not possible to receive an SPI in pcpu0 or pcpu1. Therefore it is not possible to change the same pending_irq on two different cpus simultaneously. --1342847746-277810854-1425899271=:9880 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --1342847746-277810854-1425899271=:9880--