Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754819AbbLANWe (ORCPT ); Tue, 1 Dec 2015 08:22:34 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:34879 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752541AbbLANWc (ORCPT ); Tue, 1 Dec 2015 08:22:32 -0500 Date: Tue, 1 Dec 2015 14:22:30 +0100 From: Michal Hocko To: Tetsuo Handa Cc: linux-mm@kvack.org, akpm@linux-foundation.org, torvalds@linux-foundation.org, mgorman@suse.de, rientjes@google.com, riel@redhat.com, hughd@google.com, oleg@redhat.com, andrea@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH -v2] mm, oom: introduce oom reaper Message-ID: <20151201132230.GF4567@dhcp22.suse.cz> References: <1448467018-20603-1-git-send-email-mhocko@kernel.org> <1448640772-30147-1-git-send-email-mhocko@kernel.org> <201511281339.JHH78172.SLOQFOFHVFOMJt@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201511281339.JHH78172.SLOQFOFHVFOMJt@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1976 Lines: 69 On Sat 28-11-15 13:39:11, Tetsuo Handa wrote: > Michal Hocko wrote: > > for write while write but the probability is reduced considerably wrt. > > Is this "while write" garbage? Fixed > > Users of mmap_sem which need it for write should be carefully reviewed > > to use _killable waiting as much as possible and reduce allocations > > requests done with the lock held to absolute minimum to reduce the risk > > even further. > > It will be nice if we can have down_write_killable()/down_read_killable(). Yes that is an idea. > > The API between oom killer and oom reaper is quite trivial. wake_oom_reaper > > updates mm_to_reap with cmpxchg to guarantee only NUll->mm transition > > NULL->mm fixed > > and oom_reaper clear this atomically once it is done with the work. > > Can't oom_reaper() become as compact as below? Good idea! I think we still need {READ,WRITE}_ONCE to prevent from any potential mis optimizations, though. Here is what I did: diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 333953bf4968..b50ce41194b3 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -477,21 +477,11 @@ static void oom_reap_vmas(struct mm_struct *mm) static int oom_reaper(void *unused) { - DEFINE_WAIT(wait); - while (true) { struct mm_struct *mm; - - prepare_to_wait(&oom_reaper_wait, &wait, TASK_UNINTERRUPTIBLE); - mm = READ_ONCE(mm_to_reap); - if (!mm) { - freezable_schedule(); - finish_wait(&oom_reaper_wait, &wait); - } else { - finish_wait(&oom_reaper_wait, &wait); - oom_reap_vmas(mm); - WRITE_ONCE(mm_to_reap, NULL); - } + wait_event_freezable(oom_reaper_wait, (mm = READ_ONCE(mm_to_reap))); + oom_reap_vmas(mm); + WRITE_ONCE(mm_to_reap, NULL); } return 0; -- Michal Hocko SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/