public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Question on IS_ERR
@ 2007-08-09  5:36 jidong xiao
  2007-08-09  6:13 ` H. Peter Anvin
  0 siblings, 1 reply; 4+ messages in thread
From: jidong xiao @ 2007-08-09  5:36 UTC (permalink / raw)
  To: linux-kernel

I saw we call IS_ERR(ptr) after executing kthread_run() each time.
But we don't need to call IS_ERR(ptr) after kmalloc().

My understanding is,
the kernel pointer ptr for IS_ERR to check should be page aligned, so
its kernel address should be less than 0xfffff000(or 0xffff ffff ffff
f000, 64bits),

kthread_run returns a struct task_struct pointer,which is always page aligned,
however the pointer returned by kmalloc() might not be page aligned,
so we cannot use IS_ERR to check.

Is my understanding correct?

Thanks
Jason

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

* Re: Question on IS_ERR
  2007-08-09  5:36 Question on IS_ERR jidong xiao
@ 2007-08-09  6:13 ` H. Peter Anvin
  2007-08-09  6:31   ` jidong xiao
  0 siblings, 1 reply; 4+ messages in thread
From: H. Peter Anvin @ 2007-08-09  6:13 UTC (permalink / raw)
  To: jidong xiao; +Cc: linux-kernel

jidong xiao wrote:
> I saw we call IS_ERR(ptr) after executing kthread_run() each time.
> But we don't need to call IS_ERR(ptr) after kmalloc().
> 
> My understanding is,
> the kernel pointer ptr for IS_ERR to check should be page aligned, so
> its kernel address should be less than 0xfffff000(or 0xffff ffff ffff
> f000, 64bits),
> 
> kthread_run returns a struct task_struct pointer,which is always page aligned,
> however the pointer returned by kmalloc() might not be page aligned,
> so we cannot use IS_ERR to check.
> 
> Is my understanding correct?
> 

No.  There is no requirement that the pointer is page-aligned.  The last
page of the address space is (in the Linux kernel) invalid by
definition, so there are in effect three kinds of pointers in the Linux
kernel: valid pointers, NULL, and ERR_PTR()s.

	-hpa

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

* Re: Question on IS_ERR
  2007-08-09  6:13 ` H. Peter Anvin
@ 2007-08-09  6:31   ` jidong xiao
  2007-08-09  7:21     ` H. Peter Anvin
  0 siblings, 1 reply; 4+ messages in thread
From: jidong xiao @ 2007-08-09  6:31 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel

On 8/9/07, H. Peter Anvin <hpa@zytor.com> wrote:
>
> No.  There is no requirement that the pointer is page-aligned.  The last
> page of the address space is (in the Linux kernel) invalid by
> definition, so there are in effect three kinds of pointers in the Linux
> kernel: valid pointers, NULL, and ERR_PTR()s.
>
>        -hpa
>

Regarding "The last page of the address space is invalid by definition",
I am wondering why do we define the last page as invalid.
The reason for defining this is just because we want to take use of
the error number handling?

Regards
Jason

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

* Re: Question on IS_ERR
  2007-08-09  6:31   ` jidong xiao
@ 2007-08-09  7:21     ` H. Peter Anvin
  0 siblings, 0 replies; 4+ messages in thread
From: H. Peter Anvin @ 2007-08-09  7:21 UTC (permalink / raw)
  To: jidong xiao; +Cc: linux-kernel

jidong xiao wrote:
> On 8/9/07, H. Peter Anvin <hpa@zytor.com> wrote:
>> No.  There is no requirement that the pointer is page-aligned.  The last
>> page of the address space is (in the Linux kernel) invalid by
>> definition, so there are in effect three kinds of pointers in the Linux
>> kernel: valid pointers, NULL, and ERR_PTR()s.
>>
>>        -hpa
>>
> 
> Regarding "The last page of the address space is invalid by definition",
> I am wondering why do we define the last page as invalid.
> The reason for defining this is just because we want to take use of
> the error number handling?
> 

Pretty much.

	-hpa

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

end of thread, other threads:[~2007-08-09  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-09  5:36 Question on IS_ERR jidong xiao
2007-08-09  6:13 ` H. Peter Anvin
2007-08-09  6:31   ` jidong xiao
2007-08-09  7:21     ` H. Peter Anvin

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