From: Oleg Nesterov <oleg@redhat.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Al Viro <viro@ZenIV.linux.org.uk>,
Dipankar Sarma <dipankar@in.ibm.com>,
Eric Dumazet <edumazet@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] rcu_dereference_check_fdtable fix/cleanups
Date: Wed, 8 Jan 2014 16:19:18 +0100 [thread overview]
Message-ID: <20140108151918.GA5156@redhat.com> (raw)
In-Reply-To: <20140108132852.GF10038@linux.vnet.ibm.com>
On 01/08, Paul E. McKenney wrote:
>
> I am not all that excited about invoking rcu_lock_acquire() outside
> of RCU...
Yes, me too. That is why I thought about the helper with a good name,
see below.
> Another approach would be to add an argument to files_fdtable()
> that is zero normally and one for "we know we don't need RCU
> protection." Then rcu_dereference_check() could be something
> like the following:
>
> #define files_fdtable(files, c) \
> (rcu_dereference_check_fdtable((files), (files)->fdt) || c)
>
> Would that work?
Yes, I considered this optiion, but this needs much more uglifications^W
changes.
Either we need to change all users of files_fdtable(), or we need something
like
#define __rcu_dereference_check_fdtable(files, unshared, fdtfd) \
rcu_dereference_check((fdtfd), unshared || lockdep_is_held(&(files)->file_lock))
#define rcu_dereference_check_fdtable(files, fdtfd)
__rcu_dereference_check_fdtable(files, false, fdtfd)
#define __files_fdtable(files)
__rcu_dereference_check_fdtable((files), true, (files)->fdt)
#define files_fdtable(files)
__rcu_dereference_check_fdtable((files), false, (files)->fdt)
Plus we need
static inline struct file *__fcheck_files(struct files_struct *files,
bool unshared, unsigned int fd)
{
struct file *file = NULL;
struct fdtable *fdt = __rcu_dereference_check_fdtable(files, unshared, files->fdt);
if (fd < fdt->max_fds)
file = __rcu_dereference_check_fdtable(files, unshared, fdt->fd[fd]);
return file;
}
doesn't look very nice...
As for 2/2, probably close_files() can simply do
/*
* It is safe to dereference the fd table without RCU or
* ->file_lock because this is the last reference to the
* files structure.
*/
fdt = rcu_dereference_raw(files->fdt);
Or we can add
#define __files_fdtable(files) \
rcu_dereference_raw((files)->fdt)
but it is not clear to me what 1/1 should do. Perhaps
static inline struct file *__fcheck_files(struct files_struct *files, unsigned int fd)
{
struct fdtable *fdt = rcu_dereference_raw(files->fdt);
struct file *file = NULL;
if (fd < fdt->max_fds)
file = rcu_dereference_raw(fdt->fd[fd]);
return file;
}
static inline struct file *fcheck_files(struct files_struct *files, unsigned int fd)
{
rcu_lockdep_assert(rcu_read_lock_held() ||
lockdep_is_held(files->file_lock),
"message");
return __fcheck_files(files, fd);
}
?
Oleg.
next prev parent reply other threads:[~2014-01-08 15:25 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-07 18:12 [PATCH 0/2] rcu_dereference_check_fdtable fix/cleanups Oleg Nesterov
2014-01-07 18:13 ` [PATCH 1/2] introduce __fcheck_files() to fix rcu_dereference_check_fdtable(), kill rcu_my_thread_group_empty() Oleg Nesterov
2014-01-07 18:13 ` [PATCH 2/2] change close_files() to use rcu_lock_acquire() to shut up RCU-lockdep Oleg Nesterov
2014-01-08 13:28 ` [PATCH 0/2] rcu_dereference_check_fdtable fix/cleanups Paul E. McKenney
2014-01-08 15:19 ` Oleg Nesterov [this message]
2014-01-09 1:16 ` Paul E. McKenney
2014-01-10 15:34 ` Oleg Nesterov
2014-01-11 6:34 ` Paul E. McKenney
2014-01-11 18:19 ` [PATCH v2 " Oleg Nesterov
2014-01-11 18:19 ` [PATCH v2 1/2] introduce __fcheck_files() to fix rcu_dereference_check_fdtable(), kill rcu_my_thread_group_empty() Oleg Nesterov
2014-01-11 18:19 ` [PATCH v2 2/2] change close_files() to use rcu_dereference_raw(files->fdt) Oleg Nesterov
2014-01-11 22:27 ` [PATCH v2 0/2] rcu_dereference_check_fdtable fix/cleanups Paul E. McKenney
2014-01-13 15:47 ` [PATCH 0/3] fget*() cleanups Oleg Nesterov
2014-01-13 15:48 ` [PATCH 1/3] fs: factor out common code in fget() and fget_raw() Oleg Nesterov
2014-01-13 23:29 ` Paul E. McKenney
2014-01-13 15:48 ` [PATCH 2/3] fs: factor out common code in fget_light() and fget_raw_light() Oleg Nesterov
2014-01-13 23:32 ` Paul E. McKenney
2014-01-13 15:49 ` [PATCH 3/3] fs: __fget_light() can use __fget() in slow path Oleg Nesterov
2014-01-13 23:37 ` Paul E. McKenney
2014-01-13 23:45 ` [PATCH 0/3] fget*() cleanups Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140108151918.GA5156@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dipankar@in.ibm.com \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.