From patchwork Wed Mar 25 06:17:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 6088581 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2B1E2BF90F for ; Wed, 25 Mar 2015 06:20:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 569E4200E8 for ; Wed, 25 Mar 2015 06:20:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6880C202F2 for ; Wed, 25 Mar 2015 06:20:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752401AbbCYGTt (ORCPT ); Wed, 25 Mar 2015 02:19:49 -0400 Received: from gum.cmpxchg.org ([85.214.110.215]:50861 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752498AbbCYGRj (ORCPT ); Wed, 25 Mar 2015 02:17:39 -0400 From: Johannes Weiner To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Torvalds , Andrew Morton , Tetsuo Handa , Huang Ying , Andrea Arcangeli , Dave Chinner , Michal Hocko , Theodore Ts'o Subject: [patch 05/12] mm: oom_kill: generalize OOM progress waitqueue Date: Wed, 25 Mar 2015 02:17:09 -0400 Message-Id: <1427264236-17249-6-git-send-email-hannes@cmpxchg.org> X-Mailer: git-send-email 2.3.3 In-Reply-To: <1427264236-17249-1-git-send-email-hannes@cmpxchg.org> References: <1427264236-17249-1-git-send-email-hannes@cmpxchg.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It turns out that the mechanism to wait for exiting OOM victims is less generic than it looks: it won't issue wakeups unless the OOM killer is disabled. The reason this check was added was the thought that, since only the OOM disabling code would wait on this queue, wakeup operations could be saved when that specific consumer is known to be absent. However, this is quite the handgrenade. Later attempts to reuse the waitqueue for other purposes will lead to completely unexpected bugs and the failure mode will appear seemingly illogical. Generally, providers shouldn't make unnecessary assumptions about consumers. This could have been replaced with waitqueue_active(), but it only saves a few instructions in one of the coldest paths in the kernel. Simply remove it. Signed-off-by: Johannes Weiner Acked-by: Michal Hocko --- mm/oom_kill.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 88aa9ba40fa5..d3490b019d46 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -437,11 +437,7 @@ void exit_oom_victim(void) { clear_thread_flag(TIF_MEMDIE); - /* - * There is no need to signal the lasst oom_victim if there - * is nobody who cares. - */ - if (!atomic_dec_return(&oom_victims) && oom_killer_disabled) + if (!atomic_dec_return(&oom_victims)) wake_up_all(&oom_victims_wait); }