Skip to contentSkip to conversation

linux/kernel/sched.c: context_switch().

DISCUSSION fabio de francesco 2 participants 4 messages Sep 8, 2010 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

There must be something I am missing in sched.c at context_switch() function definition.

There I can read the following code:

static inline void
context_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)

{
	...
	struct mm_struct *mm;
	mm = next->mm;
	if (likely(!mm)) {
                next->active_mm = oldmm;
                atomic_inc(&oldmm->mm_count);
                enter_lazy_tlb(oldmm, next);
        } else
                switch_mm(oldmm, mm, next);
	...
}

May someone please explain why the mm pointer is likely supposed to be NULL?

Thanks in advance.

fabio

#1 lore raw

Long day? Do you mean likely(!mm) actually means unlikely(0)?

Quoted 32 lines · fabio de francesco

There must be something I am missing in sched.c at context_switch() function definition.

There I can read the following code:

static inline void
context_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next)
{
       ...
       struct mm_struct *mm;
       mm = next->mm;
       if (likely(!mm)) {
               next->active_mm = oldmm; atomic_inc(&oldmm->mm_count); enter_lazy_tlb(oldmm, next);
       } else
               switch_mm(oldmm, mm, next);
       ...
}

May someone please explain why the mm pointer is likely supposed to be NULL?

Thanks in advance.

fabio
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

#2 lore raw
Quoted 1 line · On Wednesday 08 September 2010 15:10:49 you wrote:

Long day? Do you mean likely(!mm) actually means unlikely(0)?

No, no. I am sorry for my poor English. I mean:"likely(!mm)" is like "likely(0)".

Quoted 33 lines · fabio de francesco
Quoted 32 lines

There must be something I am missing in sched.c at context_switch() function definition.

There I can read the following code:

static inline void
context_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)

{
       ...
       struct mm_struct *mm;
       mm = next->mm;
       if (likely(!mm)) {
               next->active_mm = oldmm;
               atomic_inc(&oldmm->mm_count);
               enter_lazy_tlb(oldmm, next);
       } else
               switch_mm(oldmm, mm, next);
       ...
}

May someone please explain why the mm pointer is likely supposed to be NULL?

Thanks in advance.

fabio
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#5 lore raw
In reply to a message not in the archive
Quoted 2 lines · On Wednesday 08 September 2010 15:22:07 you wrote:

but there is a ! not operator, !mm means mm != 0 , or the other way it is saying it is unlikey(mm is NULL)

Ok. Let me point to Linux-2.6.32. You may see that there the opposite is written. Can you please explain why they changed unlikely with likely passing from 2.6.32 to 2.6.33?

Quoted 40 lines · fabio de francesco
Quoted 39 lines · On Wednesday 08 September 2010 15:10:49 you wrote:
Quoted 1 line

Long day? Do you mean likely(!mm) actually means unlikely(0)?

No, no. I am sorry for my poor English. I mean:"likely(!mm) is like "likely(0)".

Quoted 33 lines · fabio de francesco
Quoted 32 lines

There must be something I am missing in sched.c at context_switch() function definition.

There I can read the following code:

static inline void
context_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)

{
       ...
       struct mm_struct *mm;
       mm = next->mm;
       if (likely(!mm)) {
               next->active_mm = oldmm;
               atomic_inc(&oldmm->mm_count);
               enter_lazy_tlb(oldmm, next);
       } else
               switch_mm(oldmm, mm, next);
       ...
}

May someone please explain why the mm pointer is likely supposed to be NULL?

Thanks in advance.

fabio
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/