linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] make inotify event handles use GFP_NOFS
@ 2009-03-18 18:27 Eric Paris
  2009-03-30 21:26 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Paris @ 2009-03-18 18:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Peter Zijlstra, balbir, Andrew Morton,
	linux-kernel@vger.kernel.org, Eric Paris, linux-fsdevel, aviro

I think this is a bandaide to shut up lockdep.  I could either figure
out lockdep classes and figure out how to reclassify inotify locks since
I believe Nick is correct when he says inotify watches pin the inode in
core so memory pressure can't evict it.  I don't want to do that as I
think the real fix is my next generation fsnotify which does zero
allocations under locks and so everything can be GFP_KERNEL.  I'm
posting this as it is clearly safe and should fix the issue.

http://marc.info/?l=linux-kernel&m=123617147432377&w=2

includes a lockdep warning that shows while we are reclaiming FS memory
and inode may get evicted which generates an IN_IGNORED message.  Half
of that code path already used GFP_NOFS but a second allocation to store
the filename was using GFP_KERNEL.  As a precaution I also moved the
audit handle_event code path to use GFP_NOFS.

This is much the same as the precaution in f04b30de3c82528 which did
something similar.

Signed-off-by: Eric Paris <eparis@redhat.com>

---

 fs/notify/inotify/inotify_user.c |    2 +-
 kernel/auditfilter.c             |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index bed766e..1634319 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -220,7 +220,7 @@ static struct inotify_kernel_event * kernel_event(s32 wd, u32 mask, u32 cookie,
 				rem = 0;
 		}
 
-		kevent->name = kmalloc(len + rem, GFP_KERNEL);
+		kevent->name = kmalloc(len + rem, GFP_NOFS);
 		if (unlikely(!kevent->name)) {
 			kmem_cache_free(event_cachep, kevent);
 			return NULL;
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index fbf24d1..a3fa2c0 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1028,7 +1028,7 @@ static void audit_update_watch(struct audit_parent *parent,
 
 		if (audit_enabled) {
 			struct audit_buffer *ab;
-			ab = audit_log_start(NULL, GFP_KERNEL,
+			ab = audit_log_start(NULL, GFP_NOFS,
 				AUDIT_CONFIG_CHANGE);
 			audit_log_format(ab, "auid=%u ses=%u",
 				audit_get_loginuid(current),
@@ -1067,7 +1067,7 @@ static void audit_remove_parent_watches(struct audit_parent *parent)
 			e = container_of(r, struct audit_entry, rule);
 			if (audit_enabled) {
 				struct audit_buffer *ab;
-				ab = audit_log_start(NULL, GFP_KERNEL,
+				ab = audit_log_start(NULL, GFP_NOFS,
 					AUDIT_CONFIG_CHANGE);
 				audit_log_format(ab, "auid=%u ses=%u",
 					audit_get_loginuid(current),



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

* Re: [PATCH] make inotify event handles use GFP_NOFS
  2009-03-18 18:27 [PATCH] make inotify event handles use GFP_NOFS Eric Paris
@ 2009-03-30 21:26 ` Andrew Morton
  2009-03-30 21:33   ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2009-03-30 21:26 UTC (permalink / raw)
  To: Eric Paris
  Cc: linux-kernel, mingo, peterz, balbir, eparis, linux-fsdevel, aviro

On Wed, 18 Mar 2009 14:27:32 -0400
Eric Paris <eparis@redhat.com> wrote:

> I think this is a bandaide to shut up lockdep.  I could either figure
> out lockdep classes and figure out how to reclassify inotify locks since
> I believe Nick is correct when he says inotify watches pin the inode in
> core so memory pressure can't evict it.

It's pretty sad to degrading the strength of the memory allocation just
to squish a lockdep report.

>  I don't want to do that as I
> think the real fix is my next generation fsnotify which does zero
> allocations under locks and so everything can be GFP_KERNEL.

I assume that's the 13-patch series further down in my todo pile.

Perhaps this workaround is suitable for 2.6.29.x, or 2.6.30 if the
13-patch-series was too late.  But do we care enough?


>  I'm
> posting this as it is clearly safe and should fix the issue.
> 
> http://marc.info/?l=linux-kernel&m=123617147432377&w=2
> 
> includes a lockdep warning that shows while we are reclaiming FS memory
> and inode may get evicted which generates an IN_IGNORED message.  Half
> of that code path already used GFP_NOFS but a second allocation to store
> the filename was using GFP_KERNEL.  As a precaution I also moved the
> audit handle_event code path to use GFP_NOFS.
> 
> This is much the same as the precaution in f04b30de3c82528 which did
> something similar.
> 


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

* Re: [PATCH] make inotify event handles use GFP_NOFS
  2009-03-30 21:26 ` Andrew Morton
@ 2009-03-30 21:33   ` Peter Zijlstra
  2009-04-03 14:34     ` Peter Zijlstra
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2009-03-30 21:33 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Paris, linux-kernel, mingo, balbir, linux-fsdevel, aviro

On Mon, 2009-03-30 at 14:26 -0700, Andrew Morton wrote:
> On Wed, 18 Mar 2009 14:27:32 -0400
> Eric Paris <eparis@redhat.com> wrote:
> 
> > I think this is a bandaide to shut up lockdep.  I could either figure
> > out lockdep classes and figure out how to reclassify inotify locks since
> > I believe Nick is correct when he says inotify watches pin the inode in
> > core so memory pressure can't evict it.
> 
> It's pretty sad to degrading the strength of the memory allocation just
> to squish a lockdep report.

Yeah, I agree, its the wrong thing to do. lockdep annotations really
aren't that hard -- also, you could also talk me through it.


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

* Re: [PATCH] make inotify event handles use GFP_NOFS
  2009-03-30 21:33   ` Peter Zijlstra
@ 2009-04-03 14:34     ` Peter Zijlstra
  2009-04-03 14:56       ` eparis
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2009-04-03 14:34 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric Paris, linux-kernel, mingo, balbir, linux-fsdevel, aviro

On Mon, 2009-03-30 at 23:33 +0200, Peter Zijlstra wrote:
> On Mon, 2009-03-30 at 14:26 -0700, Andrew Morton wrote:
> > On Wed, 18 Mar 2009 14:27:32 -0400
> > Eric Paris <eparis@redhat.com> wrote:
> > 
> > > I think this is a bandaide to shut up lockdep.  I could either figure
> > > out lockdep classes and figure out how to reclassify inotify locks since
> > > I believe Nick is correct when he says inotify watches pin the inode in
> > > core so memory pressure can't evict it.
> > 
> > It's pretty sad to degrading the strength of the memory allocation just
> > to squish a lockdep report.
> 
> Yeah, I agree, its the wrong thing to do. lockdep annotations really
> aren't that hard -- also, you could also talk me through it.

static struct lock_class_key inotify_mutex_free;


     /*
      * here the inotify mutex gets moved to a different
      * data structure with different locking semantics while
      * holding inotify_mutex.
      */
     lock_set_class(&foo->inotify_mutex.dep_map, "inotify_mutex_free",
                     &inotify_mutex_free, 0, _THIS_IP_);


Or when done without holding the inotify_mutex


     /*
      * here the inotify mutex gets moved to a different
      * data structure with different locking semantics.
      */
     lockdep_set_class(&foo->inotify_mutex, &inotify_mutex_free);


Is all there should be to it.

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

* Re: [PATCH] make inotify event handles use GFP_NOFS
  2009-04-03 14:34     ` Peter Zijlstra
@ 2009-04-03 14:56       ` eparis
  0 siblings, 0 replies; 5+ messages in thread
From: eparis @ 2009-04-03 14:56 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Andrew Morton, linux-kernel@vger.kernel.org, mingo@elte.hu,
	balbir@linux.vnet.ibm.com, linux-fsdevel@vger.kernel.org,
	aviro@redhat.com





On Apr 3, 2009, at 10:33 AM, Peter Zijlstra <peterz@infradead.org>  
wrote:

> On Mon, 2009-03-30 at 23:33 +0200, Peter Zijlstra wrote:
>> On Mon, 2009-03-30 at 14:26 -0700, Andrew Morton wrote:
>>> On Wed, 18 Mar 2009 14:27:32 -0400
>>> Eric Paris <eparis@redhat.com> wrote:
>>>
>>>> I think this is a bandaide to shut up lockdep.  I could either  
>>>> figure
>>>> out lockdep classes and figure out how to reclassify inotify  
>>>> locks since
>>>> I believe Nick is correct when he says inotify watches pin the  
>>>> inode in
>>>> core so memory pressure can't evict it.
>>>
>>> It's pretty sad to degrading the strength of the memory allocation  
>>> just
>>> to squish a lockdep report.
>>
>> Yeah, I agree, its the wrong thing to do. lockdep annotations really
>> aren't that hard -- also, you could also talk me through it.
>
> static struct lock_class_key inotify_mutex_free;
>
>
>     /*
>      * here the inotify mutex gets moved to a different
>      * data structure with different locking semantics while
>      * holding inotify_mutex.
>      */
>     lock_set_class(&foo->inotify_mutex.dep_map, "inotify_mutex_free",
>                     &inotify_mutex_free, 0, _THIS_IP_);
>
>
> Or when done without holding the inotify_mutex
>
>
>     /*
>      * here the inotify mutex gets moved to a different
>      * data structure with different locking semantics.
>      */
>     lockdep_set_class(&foo->inotify_mutex, &inotify_mutex_free);
>
>
> Is all there should be to it.

Thanks I'll try to send something soon.

-Eric

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

end of thread, other threads:[~2009-04-03 14:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18 18:27 [PATCH] make inotify event handles use GFP_NOFS Eric Paris
2009-03-30 21:26 ` Andrew Morton
2009-03-30 21:33   ` Peter Zijlstra
2009-04-03 14:34     ` Peter Zijlstra
2009-04-03 14:56       ` eparis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).