Comment 5 for bug 71575

Revision history for this message
Ben Collins (ben-collins) wrote : Re: [Bug 71575] Re: /proc/sys/vm/drop_caches should be able to be configured to allow regular user writes

On Mon, 2006-11-20 at 01:19 +0000, Robert Collins wrote:
> On Mon, 2006-11-20 at 01:00 +0000, Ben Collins wrote:
> > You need root, or CAP_ADMIN. Not really going to make it so you can
> > write to it as normal user, since either of the other options is just as
> > simple.
>
> Sorry, I dont quite get that.
>
> My use case is not that a normal user can do it adhoc, but that it can
> be configured to be done via a normal user.
>
> I presume that by 'other options' you mean CAP_ADMIN/root - neither of
> which are appropriate for running performance test suites, which is why
> I am asking for this.
>
> I can completely understand that this isn't something you're interested
> in fixing yourself, but if you throw me a vague pointer at the relevant
> code I can look into it, or can we mark it upstream [I'm disagreeing
> that this is an invalid request] ?

This is really a question you should be posing to linux-kernel. Saying
that "performance testing shouldn't require root" is somewhat not true,
especially in cases where you are causing cache misses. You need special
perms, you need to setup the system to do it, no matter what your
choices.

So either you chmod the file (if the kernel were patched to recognize
that), or you create a special program setuid root.

I'm not sure why the perms seem easier to you, but this small program,
compiled and setuid root does it without worrying about the kernel you
are running the tests on:

int main()
{
        int fd = open("/proc/sys/vm/drop_caches", O_WRONLY);
        write(fd, "1\n", 2);
        close(fd);
}

This isn't a matter of whether I want to fix it, it's a matter of I
can't see the need, and I've no idea if there's a reason for the way it
is. Best suggestion I can give is to use the program mentioned, or start
a discussion about it on the linux-kernel mailing list where people more
advised than I can discuss it.