From patchwork Sun Jul 8 10:35:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10513117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 42FF96037F for ; Sun, 8 Jul 2018 11:10:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E61712896D for ; Sun, 8 Jul 2018 11:10:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7A9928979; Sun, 8 Jul 2018 11:10:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F31342896D for ; Sun, 8 Jul 2018 11:10:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 964006B0006; Sun, 8 Jul 2018 07:10:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 915F46B0007; Sun, 8 Jul 2018 07:10:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82A5A6B0008; Sun, 8 Jul 2018 07:10:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 42E376B0006 for ; Sun, 8 Jul 2018 07:10:37 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id f9-v6so8717240pfn.22 for ; Sun, 08 Jul 2018 04:10:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=Qm1THZVB/GMnzk8CrV/J1NCgy5CPOpUA0IGlRYi8ZWY=; b=kMwDEVqZtLhNpNbwzw+cEngS6OH7DUQK+DwpWPTYffKWkzuaHjN26fLMtSWKz+FFVG cOa0u1QkQ4bp8WDuUIpM0gf3DPI8Lb5EToskJVNQVaYmIJGwA109pm1SYAM6EKEkefxR frzkWH/nAyrFyI+YPnGIG3K1lkaVweo3CvTMISlbF/FBZzepSki41ShRZjEtSNIRlvCR El0MFLVzXP7O7UyI7mVKBjhhjorA/o6yxNvcYq6cnvAURzaioI/jtbJWlm/pqb5mstGn QJqNmQjorc6X1OFybXTb/T9WoEIxpfq3Y65ZwEkf6APy+zqAnbt4tMIEDNsUp2hRJsjD 2kog== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp X-Gm-Message-State: APt69E3a84avMssOmAVGZuTykT2LxvfR/3I9OUtv97SEGPWIqci9FA0G nT0SOGGcBdy1waMlFOf6w+LeJbTakim5CqevSsb3RH99VpJbU7awb3gHSrlUaPmimlmw9sOCXmc 3/oZZXHjYu2YXHr7i9o2Q9IbFMj049DzK/IqIHBf/cjWAHC6J6S77aHEQ84xtK4vz8w== X-Received: by 2002:a17:902:280b:: with SMTP id e11-v6mr16584991plb.298.1531048236928; Sun, 08 Jul 2018 04:10:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcm+uYlzbCG5QP0OoCsR+GEl1xQVJPJkB0+3J4nhXOlIWECXrmi0WU2kQlMNcfxLDdk2TJb X-Received: by 2002:a17:902:280b:: with SMTP id e11-v6mr16584955plb.298.1531048236151; Sun, 08 Jul 2018 04:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531048236; cv=none; d=google.com; s=arc-20160816; b=X/z12RGwAYumUMjuHjMRg8okPRDsQ3cW0StN70waWIlUw41zK7hXjAi5l+D9UJFKe0 rkM1Jdss1VLAXLzPH+6bWlDPNHREY8P9gfpMHRokOR14ouvWiNB4P0fB4FXoZdrBuhMw xI/iIBlwBRvWCtMFiCtvHPq1395/UK1gKLo8fY+3lhklWHpI9FRNx5/8D325Fq3mSb4d KnplKCCPpbxEDWyblzCdr/3wLXmVX0F44yF3FUoJqJIwtryBQH60iuykqLPCHkb8yD5d HFhOrPCQn4v27iFVgcn8RpRe7eoqQ9i4lPkB8MLMuCLHq8zFBAErl5UQQ3TSqK1ryOwE BaAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=Qm1THZVB/GMnzk8CrV/J1NCgy5CPOpUA0IGlRYi8ZWY=; b=Acoiu03wwGeo8sAl1OB88cKFrVfGGwMR6PcOuprj1IDICFdVJocsFdRzUvQZxfF1ub ZvJMwDDw7Da19fl6/VmmzXkPUXe+37oNemBezwsweg2eFq5uu/xhZLd2jIGNZUiT+nbI sNBIJNeh8o4Hiw/YRZNGPa8zPFtTY2COI0BX8O4uwPmHBsiN9BcfcNAkwDv7kbaOLms+ gVlGO4iiwSnyo6KfHfV5nPqpCPc6IB9oj9FqhjI4RjFNoG7L5GjAJfhdJUGPh+z3W9eH CDS7I9UbubW8hjfgN4us34UE/MF9fzy93PFAxQQHTRhMg3tb12oZrNlK5Yum46aQzmHQ 9zTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [202.181.97.72]) by mx.google.com with ESMTPS id h3-v6si12381956pld.114.2018.07.08.04.10.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jul 2018 04:10:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) client-ip=202.181.97.72; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from fsav305.sakura.ne.jp (fsav305.sakura.ne.jp [153.120.85.136]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w68AaBr3066954; Sun, 8 Jul 2018 19:36:11 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav305.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav305.sakura.ne.jp); Sun, 08 Jul 2018 19:36:11 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav305.sakura.ne.jp) Received: from ccsecurity.localdomain (softbank126074194044.bbtec.net [126.74.194.44]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w68Aa64s066929 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 8 Jul 2018 19:36:11 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Michal Hocko , Tetsuo Handa , David Rientjes , Hillf Danton , Johannes Weiner , Joonsoo Kim , Mel Gorman , Vladimir Davydov , Vlastimil Babka Subject: [PATCH] mm, page_alloc: PF_WQ_WORKER should always sleep at should_reclaim_retry(). Date: Sun, 8 Jul 2018 19:35:58 +0900 Message-Id: <1531046158-4010-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko should_reclaim_retry() should be a natural reschedule point. PF_WQ_WORKER is a special case which needs a stronger rescheduling policy. However, since schedule_timeout_uninterruptible(1) for PF_WQ_WORKER depends on __zone_watermark_ok() == true, PF_WQ_WORKER is currently counting on mutex_trylock(&oom_lock) == 0 in __alloc_pages_may_oom() which is a bad expectation. Doing schedule_timeout_uninterruptible(1) at should_reclaim_retry() unconditionally seems more straightforward than depending on a zone being a good candidate for a further reclaim. Signed-off-by: Michal Hocko Cc: Hillf Danton Cc: David Rientjes Cc: Johannes Weiner Cc: Joonsoo Kim Cc: Mel Gorman Cc: Tetsuo Handa Cc: Vladimir Davydov Cc: Vlastimil Babka --- mm/page_alloc.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1521100..f56cc09 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3922,6 +3922,7 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) { struct zone *zone; struct zoneref *z; + bool ret = false; /* * Costly allocations might have made a progress but this doesn't mean @@ -3985,25 +3986,26 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) } } - /* - * Memory allocation/reclaim might be called from a WQ - * context and the current implementation of the WQ - * concurrency control doesn't recognize that - * a particular WQ is congested if the worker thread is - * looping without ever sleeping. Therefore we have to - * do a short sleep here rather than calling - * cond_resched(). - */ - if (current->flags & PF_WQ_WORKER) - schedule_timeout_uninterruptible(1); - else - cond_resched(); - - return true; + ret = true; + goto out; } } - return false; +out: + /* + * Memory allocation/reclaim might be called from a WQ + * context and the current implementation of the WQ + * concurrency control doesn't recognize that + * a particular WQ is congested if the worker thread is + * looping without ever sleeping. Therefore we have to + * do a short sleep here rather than calling + * cond_resched(). + */ + if (current->flags & PF_WQ_WORKER) + schedule_timeout_uninterruptible(1); + else + cond_resched(); + return ret; } static inline bool