* [PATCH] x86: DS cleanup - dont treat 0 as NULL
@ 2008-04-28 19:15 Cyrill Gorcunov
2008-04-28 19:45 ` H. Peter Anvin
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Cyrill Gorcunov @ 2008-04-28 19:15 UTC (permalink / raw)
To: Ingo Molnar, H. Peter Anvin, Markus Metzger; +Cc: LKML
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Actually I wonder why in original code Atom processors was
_that_ aligned? Was it made with a special purpose? yes,
it's a mobile platform, but can't see any reason for such
alignment.
arch/x86/kernel/ds.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kernel/ds.c b/arch/x86/kernel/ds.c
index 5b32b6d..24a323c 100644
--- a/arch/x86/kernel/ds.c
+++ b/arch/x86/kernel/ds.c
@@ -238,12 +238,12 @@ static inline struct ds_context *ds_alloc_context(struct task_struct *task)
context = kzalloc(sizeof(*context), GFP_KERNEL);
if (!context)
- return 0;
+ return NULL;
context->ds = kzalloc(ds_cfg.sizeof_ds, GFP_KERNEL);
if (!context->ds) {
kfree(context);
- return 0;
+ return NULL;
}
*p_context = context;
@@ -279,7 +279,7 @@ static inline void ds_put_context(struct ds_context *context)
if (--context->count)
goto out;
- *(context->this) = 0;
+ *(context->this) = NULL;
if (context->task)
clear_tsk_thread_flag(context->task, TIF_DS_AREA_MSR);
@@ -341,16 +341,16 @@ static inline void *ds_allocate_buffer(size_t size, unsigned int *pages)
rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
vm = current->mm->total_vm + pgsz;
if (rlim < vm)
- return 0;
+ return NULL;
rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
vm = current->mm->locked_vm + pgsz;
if (rlim < vm)
- return 0;
+ return NULL;
buffer = kzalloc(size, GFP_KERNEL);
if (!buffer)
- return 0;
+ return NULL;
current->mm->total_vm += pgsz;
current->mm->locked_vm += pgsz;
@@ -395,7 +395,7 @@ static int ds_request(struct task_struct *task, void *base, size_t size,
if (context->owner[qual] == current)
goto out_unlock;
error = -EPERM;
- if (context->owner[qual] != 0)
+ if (context->owner[qual] != NULL)
goto out_unlock;
context->owner[qual] = current;
@@ -445,7 +445,7 @@ static int ds_request(struct task_struct *task, void *base, size_t size,
return error;
out_release:
- context->owner[qual] = 0;
+ context->owner[qual] = NULL;
ds_put_context(context);
return error;
@@ -825,7 +825,7 @@ void __cpuinit ds_init_intel(struct cpuinfo_x86 *c)
ds_configure(&ds_cfg_var);
break;
case 0xF: /* Core2 */
- case 0x1C: /* Atom */
+ case 0x1C: /* Atom */
ds_configure(&ds_cfg_64);
break;
default:
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH] x86: DS cleanup - dont treat 0 as NULL
2008-04-28 19:15 [PATCH] x86: DS cleanup - dont treat 0 as NULL Cyrill Gorcunov
@ 2008-04-28 19:45 ` H. Peter Anvin
2008-04-28 19:46 ` H. Peter Anvin
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: H. Peter Anvin @ 2008-04-28 19:45 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: Ingo Molnar, Markus Metzger, LKML
Cyrill Gorcunov wrote:
>
> Actually I wonder why in original code Atom processors was
> _that_ aligned? Was it made with a special purpose? yes,
> it's a mobile platform, but can't see any reason for such
> alignment.
>
I'm sorry, I don't see how this comment has anything to do with this patch?
-hpa
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] x86: DS cleanup - dont treat 0 as NULL
2008-04-28 19:15 [PATCH] x86: DS cleanup - dont treat 0 as NULL Cyrill Gorcunov
2008-04-28 19:45 ` H. Peter Anvin
@ 2008-04-28 19:46 ` H. Peter Anvin
2008-04-28 20:00 ` Cyrill Gorcunov
2008-04-28 20:02 ` Ingo Molnar
2008-04-29 6:23 ` David Newall
3 siblings, 1 reply; 9+ messages in thread
From: H. Peter Anvin @ 2008-04-28 19:46 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: Ingo Molnar, Markus Metzger, LKML
Cyrill Gorcunov wrote:
>
> Actually I wonder why in original code Atom processors was
> _that_ aligned? Was it made with a special purpose? yes,
> it's a mobile platform, but can't see any reason for such
> alignment.
>
[...]
> @@ -825,7 +825,7 @@ void __cpuinit ds_init_intel(struct cpuinfo_x86 *c)
> ds_configure(&ds_cfg_var);
> break;
> case 0xF: /* Core2 */
> - case 0x1C: /* Atom */
> + case 0x1C: /* Atom */
> ds_configure(&ds_cfg_64);
> break;
> default:
>
Nevermind, I was looking for a *memory* alignment... :-/
-hpa
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] x86: DS cleanup - dont treat 0 as NULL
2008-04-28 19:15 [PATCH] x86: DS cleanup - dont treat 0 as NULL Cyrill Gorcunov
2008-04-28 19:45 ` H. Peter Anvin
2008-04-28 19:46 ` H. Peter Anvin
@ 2008-04-28 20:02 ` Ingo Molnar
2008-04-29 6:23 ` David Newall
3 siblings, 0 replies; 9+ messages in thread
From: Ingo Molnar @ 2008-04-28 20:02 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: H. Peter Anvin, Markus Metzger, LKML
* Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
thanks Cyrill, applied.
> @@ -825,7 +825,7 @@ void __cpuinit ds_init_intel(struct cpuinfo_x86 *c)
> ds_configure(&ds_cfg_var);
> break;
> case 0xF: /* Core2 */
> - case 0x1C: /* Atom */
> + case 0x1C: /* Atom */
> ds_configure(&ds_cfg_64);
> break;
to me it looks like a typo, not a sign of any real bug/thinko. The
processor IDs there are a flat list.
Ingo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] x86: DS cleanup - dont treat 0 as NULL
2008-04-28 19:15 [PATCH] x86: DS cleanup - dont treat 0 as NULL Cyrill Gorcunov
` (2 preceding siblings ...)
2008-04-28 20:02 ` Ingo Molnar
@ 2008-04-29 6:23 ` David Newall
2008-04-29 6:38 ` H. Peter Anvin
2008-04-29 7:50 ` Cyrill Gorcunov
3 siblings, 2 replies; 9+ messages in thread
From: David Newall @ 2008-04-29 6:23 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: Ingo Molnar, H. Peter Anvin, Markus Metzger, LKML
Cyrill Gorcunov wrote:
> - return 0;
> + return NULL;
Why? The constant 0 is C's official symbol for a null pointer.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] x86: DS cleanup - dont treat 0 as NULL
2008-04-29 6:23 ` David Newall
@ 2008-04-29 6:38 ` H. Peter Anvin
2008-04-29 17:30 ` David Newall
2008-04-29 7:50 ` Cyrill Gorcunov
1 sibling, 1 reply; 9+ messages in thread
From: H. Peter Anvin @ 2008-04-29 6:38 UTC (permalink / raw)
To: David Newall; +Cc: Cyrill Gorcunov, Ingo Molnar, Markus Metzger, LKML
David Newall wrote:
> Cyrill Gorcunov wrote:
>> - return 0;
>> + return NULL;
>
> Why? The constant 0 is C's official symbol for a null pointer.
It's still bad style.
-hpa
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] x86: DS cleanup - dont treat 0 as NULL
2008-04-29 6:38 ` H. Peter Anvin
@ 2008-04-29 17:30 ` David Newall
0 siblings, 0 replies; 9+ messages in thread
From: David Newall @ 2008-04-29 17:30 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Cyrill Gorcunov, Ingo Molnar, Markus Metzger, LKML
H. Peter Anvin wrote:
> David Newall wrote:
>> Cyrill Gorcunov wrote:
>>> - return 0;
>>> + return NULL;
>>
>> Why? The constant 0 is C's official symbol for a null pointer.
>
> It's still bad style.
I disagree, but I don't want to debate the point.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] x86: DS cleanup - dont treat 0 as NULL
2008-04-29 6:23 ` David Newall
2008-04-29 6:38 ` H. Peter Anvin
@ 2008-04-29 7:50 ` Cyrill Gorcunov
1 sibling, 0 replies; 9+ messages in thread
From: Cyrill Gorcunov @ 2008-04-29 7:50 UTC (permalink / raw)
To: David Newall; +Cc: Ingo Molnar, H. Peter Anvin, Markus Metzger, LKML
On Tue, Apr 29, 2008 at 10:23 AM, David Newall <davidn@davidnewall.com> wrote:
> Cyrill Gorcunov wrote:
> > - return 0;
> > + return NULL;
>
> Why? The constant 0 is C's official symbol for a null pointer.
>
Yes, but by using NULL explicilty allows you to separate _pointers_ from
numbers on review process. Or maybe you wanna drop NULL at all? I dont
think you will like that ;)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-04-29 17:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-28 19:15 [PATCH] x86: DS cleanup - dont treat 0 as NULL Cyrill Gorcunov
2008-04-28 19:45 ` H. Peter Anvin
2008-04-28 19:46 ` H. Peter Anvin
2008-04-28 20:00 ` Cyrill Gorcunov
2008-04-28 20:02 ` Ingo Molnar
2008-04-29 6:23 ` David Newall
2008-04-29 6:38 ` H. Peter Anvin
2008-04-29 17:30 ` David Newall
2008-04-29 7:50 ` Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox