2004-01-01 12:03:58

by Michel Dänzer

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Wed, 2003-12-31 at 19:21, Jon Smirl wrote:
> The headers for nopageXX calls just changed.
>
> struct page * (*nopage)(struct vm_area_struct * area, unsigned long address, int
> unused);
> changed to:
> struct page * (*nopage)(struct vm_area_struct * area, unsigned long address, int
> *type);
>
> The DRM drivers need to be adjusted. This probably impacts the BSD builds.

No, this is Linux specific.

How does this patch look?


--
Earthling Michel Dänzer | Debian (powerpc), X and DRI developer
Software libre enthusiast | http://svcs.affero.net/rm.php?r=daenzer


Attachments:
drm-nopage.diff (6.27 kB)

2004-01-01 12:11:15

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Thu, 2004-01-01 at 13:03, Michel Dänzer wrote:

> How does this patch look?

ugly.

I find using #defines for function arguments ugly beyond belief and
makes it really hard to look through code. I 10x rather have an ifdef in
the function prototype (which then for the mainstream kernel drm can be
removed for non-matching versions) than such obfuscation.


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part

2004-01-01 12:23:43

by Michel Dänzer

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Thu, 2004-01-01 at 13:10, Arjan van de Ven wrote:
> On Thu, 2004-01-01 at 13:03, Michel Dänzer wrote:
>
> > How does this patch look?
>
> ugly.
>
> I find using #defines for function arguments ugly beyond belief and
> makes it really hard to look through code. I 10x rather have an ifdef in
> the function prototype (which then for the mainstream kernel drm can be
> removed for non-matching versions) than such obfuscation.

That doesn't strike me as particularly beautiful either... is it really
easier for merges, considering that the ugly way is kinda needed for
functions which take different arguments on BSD anyway?


--
Earthling Michel Dänzer | Debian (powerpc), X and DRI developer
Software libre enthusiast | http://svcs.affero.net/rm.php?r=daenzer

2004-01-01 12:29:05

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Thu, Jan 01, 2004 at 01:23:40PM +0100, Michel D?nzer wrote:
> > > How does this patch look?
> >
> > ugly.
> >
> > I find using #defines for function arguments ugly beyond belief and
> > makes it really hard to look through code. I 10x rather have an ifdef in
> > the function prototype (which then for the mainstream kernel drm can be
> > removed for non-matching versions) than such obfuscation.
>
> That doesn't strike me as particularly beautiful either...

well the advantage is that the ifdefs can just go away in kernel trees of
specific versions... (eg unifdef it)

> is it really easier for merges, considering that the ugly way is kinda
> needed for functions which take different arguments on BSD anyway?

I disagree there. The "BSD takes different arguments" thing *should* be
fixed imo by making the common core of the function an inline function, and have
one or two (depends if the common core happens to have its arguments in common
with one of the oses) OS specific wrappers with the right prototype. This
way the difference in error return sign can also be solved in the wrapper
instead of with a nasty macro...

The compiler generates the same code, but it's a lot easier to read/review.

Greetings,
Arjan van de Ven


Attachments:
(No filename) (1.22 kB)
(No filename) (189.00 B)
Download all attachments

2004-01-01 13:33:15

by William Lee Irwin III

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Thu, Jan 01, 2004 at 01:03:38PM +0100, Michel D?nzer wrote:
> No, this is Linux specific.
> How does this patch look?

Okay, you did something weird with nopage args, but I thought I did
the equivalent of this in the original patch?


-- wli

2004-01-01 13:50:34

by Michel Dänzer

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Thu, 2004-01-01 at 14:33, William Lee Irwin III wrote:
> On Thu, Jan 01, 2004 at 01:03:38PM +0100, Michel D?nzer wrote:
> > No, this is Linux specific.
> > How does this patch look?
>
> Okay, you did something weird with nopage args, but I thought I did
> the equivalent of this in the original patch?

This is about the canonical DRM code in the DRI tree.


--
Earthling Michel Dänzer | Debian (powerpc), X and DRI developer
Software libre enthusiast | http://svcs.affero.net/rm.php?r=daenzer

2004-01-01 14:13:49

by William Lee Irwin III

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Thu, 2004-01-01 at 14:33, William Lee Irwin III wrote:
>> Okay, you did something weird with nopage args, but I thought I did
>> the equivalent of this in the original patch?

On Thu, Jan 01, 2004 at 02:50:30PM +0100, Michel D?nzer wrote:
> This is about the canonical DRM code in the DRI tree.

I'm sorry, I'm not going to drive myself insane trying to deal with
yet another overweight and insanely ugly BSD emulation layer. I'll
stick with canonical kernel.org sources, thank you very much.


-- wli

2004-01-01 14:28:18

by Michel Dänzer

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Thu, 2004-01-01 at 13:28, Arjan van de Ven wrote:
> On Thu, Jan 01, 2004 at 01:23:40PM +0100, Michel Dänzer wrote:
> > >
> > > I find using #defines for function arguments ugly beyond belief and
> > > makes it really hard to look through code. I 10x rather have an ifdef in
> > > the function prototype (which then for the mainstream kernel drm can be
> > > removed for non-matching versions) than such obfuscation.
> >
> > That doesn't strike me as particularly beautiful either...
>
> well the advantage is that the ifdefs can just go away in kernel trees of
> specific versions... (eg unifdef it)

Does this look better? Maybe a macro (or a typedef?) for the type of the
last argument would still be a good idea? Or is there yet a better way?


> > is it really easier for merges, considering that the ugly way is kinda
> > needed for functions which take different arguments on BSD anyway?
>
> I disagree there. The "BSD takes different arguments" thing *should* be
> fixed imo by making the common core of the function an inline function, and have
> one or two (depends if the common core happens to have its arguments in common
> with one of the oses) OS specific wrappers with the right prototype. This
> way the difference in error return sign can also be solved in the wrapper
> instead of with a nasty macro...
>
> The compiler generates the same code, but it's a lot easier to read/review.

Interesting, sounds like food for thought for Eric Anholt. :)


--
Earthling Michel Dänzer | Debian (powerpc), X and DRI developer
Software libre enthusiast | http://svcs.affero.net/rm.php?r=daenzer


Attachments:
drm-nopage.diff (6.17 kB)

2004-01-01 15:07:07

by William Lee Irwin III

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Thu, Jan 01, 2004 at 03:27:59PM +0100, Michel D?nzer wrote:
> Does this look better? Maybe a macro (or a typedef?) for the type of the
> last argument would still be a good idea? Or is there yet a better way?

I'm going to regret suggesting this, but how about:
(a) a typedef for the arg itself
(b) a macro and/or inline for the type update

both simultaneously?

So we'd have centralized in one place:

#if /* kernel version > 2.6.0 */
typdef int *third_arg_t;
#define third_arg_update(type) do { *(type) = VM_FAULT_MINOR; } while (0)
#else
typdef int third_arg_t;
#define third_arg_update(type) do { } while (0)
#endif

... and the natural usage that follows.

-- wli

2004-01-01 17:59:40

by Alan

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Iau, 2004-01-01 at 13:50, Michel Dänzer wrote:
> > Okay, you did something weird with nopage args, but I thought I did
> > the equivalent of this in the original patch?
>
> This is about the canonical DRM code in the DRI tree.

99.9% of people run the DRM code in the kernel tree, so definitions of
canonical might vary. I don't personally see a problem with the ifdefs.
The DRI devel tree has to work with anything, the kernel gets the luxury
of being able to strip out the defines that aren't needed for that
specific release.

Alan

2004-01-01 20:25:22

by Linus Torvalds

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage



On Thu, 1 Jan 2004, Michel D?nzer wrote:
>
> > well the advantage is that the ifdefs can just go away in kernel trees of
> > specific versions... (eg unifdef it)
>
> Does this look better? Maybe a macro (or a typedef?) for the type of the
> last argument would still be a good idea? Or is there yet a better way?

My preference is either:

- we can still undo the "nopage" argument change. It's been in the -mm
tree for a long time, and it _does_ solve a problem (page fault type
accounting), but the problem it solves is potentially so small that we
might decide it's ok for 2.6.x.

However, Andrew is king, and besides, it does fix a tiny bug, so I
don't think this is what we should do. I just wanted to put it on the
table as a possibility.

- Use separate (and trivial) wrapper functions for this. Keep the "real"
function the same across everything, and just have a _static_ function
(ie no header file declaration crap) that does

linux-new-vm.h:

static int DRM(nopage_interface)(struct vm_area_struct * area,
unsigned long address,
int *type)
{
*type = VM_FAULT_MINOR;
DRM(nopage)(area, address);
}


linux-old-vm.h:

static int DRM(nopage_interface)(struct vm_area_struct * area,
unsigned long address,
int unused)
{
DRM(nopage)(area, address);
}


drm_vm.h:

/*
* Or, poreferably, we could create a symlink and avoid
* the #if's at compile-time _entirely_.
*/
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
#include "linux-new-vm.h"
#else
#include "linux-old-v.h
#endif

..
.nopage = nopage_interface;
..

Done right, the virtualization could be a bit higher still, and maybe
the BSD code can do the same thing.

In general, at least I personally _much_ prefer the #ifdef's etc to be
outside the code. So even if you don't like to have separate small files
for different architectures/ports/versions, I'd at least personally
much rather have

#if xxxx

int onewholefunction(..)
...


#else

int onewholefunction(..)
...

#endif

rather than the messy

int onewholefunction(
#if xxx
..
#else
..
#endif
(
{
...
#if xxxx
..
#endif

The latter is a huge pain not just to read (you go blind after a while),
but it's also painful as _hell_ to merge anywhere else.

In contrast, full-file interfaces for different kernel versions are a
_lot_ easier to merge and keep track of. They may look like "duplication",
but the advantages are legion. You don't mix different OS's and different
versions together, and that makes it much easier to support them all
without going crazy.

Linus

2004-01-01 21:16:35

by Nigel Cunningham

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Fri, 2004-01-02 at 09:19, Linus Torvalds wrote:
> In contrast, full-file interfaces for different kernel versions are a
> _lot_ easier to merge and keep track of. They may look like "duplication",
> but the advantages are legion. You don't mix different OS's and different
> versions together, and that makes it much easier to support them all
> without going crazy.

Of course there are also advantages to _not_ using the file-per-kernel
version scheme. Keeping one set of files means time is not wasted
applying the same change to multiple variations, removes the possibility
of patches getting applied to one version and not another and simplifies
the process of continuing to support old kernel versions. For merging, a
bit of test processing on the files could always be used to remove the
ugliness and clean things up.

Regards,

Nigel
--
My work on Software Suspend is graciously brought to you by
LinuxFund.org.

2004-01-01 22:58:06

by Linus Torvalds

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage



On Fri, 2 Jan 2004, Nigel Cunningham wrote:
>
> Of course there are also advantages to _not_ using the file-per-kernel
> version scheme.

No there isn't.

The thing is, you should keep those "file-per-OS" files as small as
possible, and only contain the things that are literally different.
Because:

> Keeping one set of files means time is not wasted
> applying the same change to multiple variations

If the files only contain the actual differences, this just isn't an
issue. Those files are per-OS _anyway_, so regardless of how you do it
(with #ifdef's inside our outside the code etc), you'd have several
versions.

And having separate files means that you don't uglify the code for another
OS or another version and hide the _real_ issues.

But yes, it assumes that you can cleanly abstract out the differences.

Linus

2004-01-10 21:54:58

by Michel Dänzer

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage


First of all, thanks for all the suggestions I've received in this
thread.

New patch up at http://penguinppc.org/~daenzer/DRI/drm-nopage.diff; does
this look acceptable to those who are going to do merges between the
trees? :)


--
Earthling Michel Dänzer | Debian (powerpc), X and DRI developer
Software libre enthusiast | http://svcs.affero.net/rm.php?r=daenzer

2004-01-10 22:08:50

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Sat, 2004-01-10 at 22:54, Michel Dänzer wrote:
> First of all, thanks for all the suggestions I've received in this
> thread.
>
> New patch up at http://penguinppc.org/~daenzer/DRI/drm-nopage.diff; does
> this look acceptable to those who are going to do merges between the
> trees? :)

I like this one a whole lot better than the previous ones...
One could argue that you want the do_ function set the pagefault type
itself (and just igore the result in the 2.4 variants) but that's minor
nitpicking at most.


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part

2004-01-11 00:15:12

by Michel Dänzer

[permalink] [raw]
Subject: Re: [Dri-devel] 2.6 kernel change in nopage

On Sat, 2004-01-10 at 23:08, Arjan van de Ven wrote:
> On Sat, 2004-01-10 at 22:54, Michel Dänzer wrote:
> > First of all, thanks for all the suggestions I've received in this
> > thread.
> >
> > New patch up at http://penguinppc.org/~daenzer/DRI/drm-nopage.diff; does
> > this look acceptable to those who are going to do merges between the
> > trees? :)
>
> I like this one a whole lot better than the previous ones...
> One could argue that you want the do_ function set the pagefault type
> itself (and just igore the result in the 2.4 variants) but that's minor
> nitpicking at most.

Okay, thanks, I just committed this.


--
Earthling Michel Dänzer | Debian (powerpc), X and DRI developer
Software libre enthusiast | http://svcs.affero.net/rm.php?r=daenzer