public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Question] I doublt on spin_lock again.
@ 2005-11-23  2:04 liyu
  2005-11-23  2:51 ` Zhang Le
  0 siblings, 1 reply; 4+ messages in thread
From: liyu @ 2005-11-23  2:04 UTC (permalink / raw)
  To: LKML

Hi, All.

    I come here again.

    I have two questions on spin_lock. these are:

    1. I found these use spin_lock(&rq->lock) in set_user_nice(), but 
not disable interrput ( e.g.  when sys_nice() call it ),  if the one 
timer interrput come before we unlock the spin_lock, Shall
we dead lock here?  Since the scheduler_tick() may try to hold the same 
lock.

    2. I also found some function name in its definition have some 
postfix, I show here two classical examples:

static void double_rq_lock(runqueue_t *rq1, runqueue_t *rq2)
    __acquires(rq1->lock)
    __acquires(rq2->lock)
{ ... }

static void double_rq_unlock(runqueue_t *rq1, runqueue_t *rq2)
    __releases(rq1->lock)
    __releases(rq2->lock)
{ ... }

    In the related header files, they are defined as two preprocess 
macroes, are follow:

# define __acquires(x)    __attribute__((context(0,1)))
# define __releases(x)    __attribute__((context(1,0)))
# define __acquire(x)    __context__(1)
# define __release(x)    __context__(-1)


    I guess they are some extensions of gcc for C language, but I did 
not  found any information in GCC manual.

    Would you like reply these questions? Thank advanced.

-liyu










^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question] I doublt on spin_lock again.
  2005-11-23  2:04 [Question] I doublt on spin_lock again liyu
@ 2005-11-23  2:51 ` Zhang Le
  2005-11-23  2:56   ` liyu
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang Le @ 2005-11-23  2:51 UTC (permalink / raw)
  To: liyu; +Cc: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

liyu wrote:

| 1. I found these use spin_lock(&rq->lock) in set_user_nice(), but
| not disable interrput ( e.g.  when sys_nice() call it ),  if the
| one timer interrput come before we unlock the spin_lock, Shall we
| dead lock here?  Since the scheduler_tick() may try to hold the
| same lock.

set_user_nice() -> task_rq_lock -> local_irq_save()

|
| 2. # define __acquires(x)    __attribute__((context(0,1))) # define
| __releases(x)    __attribute__((context(1,0))) # define
| __acquire(x)    __context__(1) # define __release(x)
| __context__(-1)

info gcc

BTW, have you ever read "HOWTO do Linux kernel development" be Greg?
Do it, if you haven't

- --
Zhang Le, Robert
Linux Engineer/Trainer

ThizLinux Laboratory Limited
Address: Unit 1004, 10/F, Tower B,
Hunghom Commercial Centre, 37 Ma Tau Wai Road,
To Kwa Wan, Kowloon, Hong Kong
Telephone: (852) 2735 2725
Mobile:(852) 9845 4336
Fax: (852) 2111 0702
URL: http://www.thizgroup.com
Public key: gpg --keyserver pgp.mit.edu --recv-keys 1E4E2973

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDg9kOvFHICB5OKXMRAg7BAJwIhyW9Qop4YGF9G56nzqImjy8UgQCfUE/g
b8pK2Fk6oW8ScK42krTZdOQ=
=mDfg
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question] I doublt on spin_lock again.
  2005-11-23  2:51 ` Zhang Le
@ 2005-11-23  2:56   ` liyu
  2005-11-23  4:09     ` Zhang Le
  0 siblings, 1 reply; 4+ messages in thread
From: liyu @ 2005-11-23  2:56 UTC (permalink / raw)
  To: Zhang Le; +Cc: linux-kernel

Zhang Le wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> liyu wrote:
>
> | 1. I found these use spin_lock(&rq->lock) in set_user_nice(), but
> | not disable interrput ( e.g.  when sys_nice() call it ),  if the
> | one timer interrput come before we unlock the spin_lock, Shall we
> | dead lock here?  Since the scheduler_tick() may try to hold the
> | same lock.
>
> set_user_nice() -> task_rq_lock -> local_irq_save()
>
> |
> | 2. # define __acquires(x)    __attribute__((context(0,1))) # define
> | __releases(x)    __attribute__((context(1,0))) # define
> | __acquire(x)    __context__(1) # define __release(x)
> | __context__(-1)
>
> info gcc
>
> BTW, have you ever read "HOWTO do Linux kernel development" be Greg?
> Do it, if you haven't
>
> - --
> Zhang Le, Robert
> Linux Engineer/Trainer
>
> ThizLinux Laboratory Limited
> Address: Unit 1004, 10/F, Tower B,
> Hunghom Commercial Centre, 37 Ma Tau Wai Road,
> To Kwa Wan, Kowloon, Hong Kong
> Telephone: (852) 2735 2725
> Mobile:(852) 9845 4336
> Fax: (852) 2111 0702
> URL: http://www.thizgroup.com
> Public key: gpg --keyserver pgp.mit.edu --recv-keys 1E4E2973
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFDg9kOvFHICB5OKXMRAg7BAJwIhyW9Qop4YGF9G56nzqImjy8UgQCfUE/g
> b8pK2Fk6oW8ScK42krTZdOQ=
> =mDfg
> -----END PGP SIGNATURE-----
>
>
>
Thanks first.

1.  I know local_irq_save() in task_rq_lock(), but it only save FLAGS 
register to one unsigned long variable, but not disable maskable interrupt.
2. OK, I am going to get it.

-liyu



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question] I doublt on spin_lock again.
  2005-11-23  2:56   ` liyu
@ 2005-11-23  4:09     ` Zhang Le
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang Le @ 2005-11-23  4:09 UTC (permalink / raw)
  To: liyu; +Cc: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

liyu wrote:

| 1.  I know local_irq_save() in task_rq_lock(), but it only save
| FLAGS register to one unsigned long variable, but not disable
| maskable interrupt.

#define local_irq_save(x)   __asm__ __volatile__("pushfl ; popl %0 ;
cli":"=g" (x): /* no
~ input */ :"memory")

- --
Zhang Le, Robert
Linux Engineer/Trainer

ThizLinux Laboratory Limited
Address: Unit 1004, 10/F, Tower B,
Hunghom Commercial Centre, 37 Ma Tau Wai Road,
To Kwa Wan, Kowloon, Hong Kong
Telephone: (852) 2735 2725
Mobile:(852) 9845 4336
Fax: (852) 2111 0702
URL: http://www.thizgroup.com
Public key: gpg --keyserver pgp.mit.edu --recv-keys 1E4E2973

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDg+tnvFHICB5OKXMRAq+UAJ9svPra7vq5Q60T89B5mA+KJMFf6wCfXPGS
Lv/nGwQkHaXUpKYfYx+dxxg=
=xjKN
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-11-23  4:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-23  2:04 [Question] I doublt on spin_lock again liyu
2005-11-23  2:51 ` Zhang Le
2005-11-23  2:56   ` liyu
2005-11-23  4:09     ` Zhang Le

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox