From patchwork Thu Jun 7 11:00:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10451649 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 0D9FC60467 for ; Thu, 7 Jun 2018 11:01:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F241E29C81 for ; Thu, 7 Jun 2018 11:01:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E735029C36; Thu, 7 Jun 2018 11:01:01 +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 70EA529C36 for ; Thu, 7 Jun 2018 11:01:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4453C6B0007; Thu, 7 Jun 2018 07:01:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 418586B0008; Thu, 7 Jun 2018 07:01:00 -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 308FC6B000A; Thu, 7 Jun 2018 07:01:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot0-f200.google.com (mail-ot0-f200.google.com [74.125.82.200]) by kanga.kvack.org (Postfix) with ESMTP id 09F1A6B0007 for ; Thu, 7 Jun 2018 07:01:00 -0400 (EDT) Received: by mail-ot0-f200.google.com with SMTP id j24-v6so5951807otk.11 for ; Thu, 07 Jun 2018 04:01:00 -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:in-reply-to:references; bh=afiCRsvsuFB6C2AashbfrHQGJD8w3jXBnHFMp0oJW68=; b=BaRmTJogJd/2TwrERilZtfY2lMAvjRnka8RW1XE3zGtMppSdkv4GHN9eYZm0GF9uUp wZUrWS+VxnDii8LewZRaJw17aDrLA8mwrcg8Kflyyfe2y8uJVRHoRkI29lG2MPkqjTzO fPP3f1DRMLROUuJVy34oo3fRHOX9wgJfJLRDY0KyFDPy0MiKmqu41ElXS7VVJm3ViyCs U7Wm/3AYk3vmgjgBBPU59DQOYQN7wkZksTpDpF+YEBa4aocSAB+9Z6ilza33D4EhXcqq jtxhaJQ+L5F1O31A5XbckYwUs70+usQd75cTv38zjcElg0SqX0rUvoft4uEImQkCSbps cNWw== 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: APt69E1+4cOVkd3MEL3xRmlEECb2PvrK4z5EqtJxagfItNYBoAf5SUVx 3kMhzzOka+xCTmuj1n0qcBmeHprril/wFnX9IQRuNRWfRmlE/6mzhMbBr3OCOLaU8LCYXNTK9Yn PSSzpWsxpJR88CJOdbPJ/x5dZ90rag/UDD2XqKvEbjCzHtgc+GmJonzuxmxxYhaqb9w== X-Received: by 2002:a9d:206f:: with SMTP id n102-v6mr724104ota.153.1528369259730; Thu, 07 Jun 2018 04:00:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLCzo1rhBMkuJgaKjRm4vs9n0WB5PnoZie6OgeLVcVIFmXUDKYCGF8XhSN+m0hOU8ZXlvTI X-Received: by 2002:a9d:206f:: with SMTP id n102-v6mr724055ota.153.1528369258909; Thu, 07 Jun 2018 04:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528369258; cv=none; d=google.com; s=arc-20160816; b=Tvi7CYV3T8p7VSNwWbcwIqPXeRAgStqbLiFTVzHRE9pcZUdUqzo8OFvzVmld8bpGhn 3hRwwFSeP+nDgIjS/ApT6O2otCL9ZcLWuJlENMzfD9/0CWbhCNISeVFE/jJn9linIpyG 3EKrnWsPNcV6C/PB0Wzrec0qvWVAI5NpHO1rfA+txRBJmjIgycaT4zvf3E7Uz8Os9v9f IslkNPAqI3gc5xIyhgZRRml7kWXAEOAtCh4GxKshheu9IQPikkyS760sVgOrvCmEG0kk YJx9tqxszcOE+hqUxndR0+6ZQGBvNA6OTkKs5FbkPknCzstFJzNiqyVHkutu60flGpO+ toow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=afiCRsvsuFB6C2AashbfrHQGJD8w3jXBnHFMp0oJW68=; b=e3BCbP0hjhEhLgHgqHIvoLOKhCf+VqcRLZBUyRXh6W5OwSbe6Np1bZixNe9V5wfDUG mwhq+LogffZiJnjbdQiglTnwrphOq3ufDACi80d69iExlTwZkDc60GqnV38QOvMzw1Ko cOiJPWR+SUbcsje2mRzOPwr1/mHa1FAJV55DsddKf259Qkoj90jbKcVEZWZRAqIM5XA6 E8OysdkC4oLa9LsY/ndmjqiEprz0KcHcQBLn2GWziIiQIovKfntUrd7o7VFYe7ashyAT l2tomtiW36Wh2EzTRsfovqZpfftxretohTeS9+zSvLjeKiPr6H3FeXRixW0ItpJncUVj U1xA== 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 102-v6si4392275oti.443.2018.06.07.04.00.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 04:00:58 -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 fsav302.sakura.ne.jp (fsav302.sakura.ne.jp [153.120.85.133]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w57B0U3V033493; Thu, 7 Jun 2018 20:00:30 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav302.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav302.sakura.ne.jp); Thu, 07 Jun 2018 20:00:30 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav302.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 w57B0OP8033466 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 7 Jun 2018 20:00:30 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Tetsuo Handa , Michal Hocko , David Rientjes , Johannes Weiner , Roman Gushchin , Tejun Heo , Vladimir Davydov Subject: [PATCH 2/4] mm, page_alloc: Move the short sleep to should_reclaim_retry() Date: Thu, 7 Jun 2018 20:00:21 +0900 Message-Id: <1528369223-7571-2-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1528369223-7571-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> References: <1528369223-7571-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> 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 should_reclaim_retry() should be a natural reschedule point. PF_WQ_WORKER is a special case which needs a stronger rescheduling policy. Doing that unconditionally seems more straightforward than depending on a zone being a good candidate for a further reclaim. Thus, move the short sleep when we are waiting for the owner of oom_lock (which coincidentally also serves as a guaranteed sleep for PF_WQ_WORKER threads) to should_reclaim_retry(). Note that it is not evaluated that whether there is negative side effect with this change. We need to test both real and artificial workloads for evaluation. You can compare with and without this patch if you noticed something unexpected. Signed-off-by: Michal Hocko Cc: Tetsuo Handa Cc: Roman Gushchin Cc: Michal Hocko Cc: Johannes Weiner Cc: Vladimir Davydov Cc: David Rientjes Cc: Tejun Heo --- mm/page_alloc.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e90f152..210a476 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3914,6 +3914,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 @@ -3977,25 +3978,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 @@ -4237,12 +4239,6 @@ bool gfp_pfmemalloc_allowed(gfp_t gfp_mask) /* Retry as long as the OOM killer is making progress */ if (did_some_progress) { no_progress_loops = 0; - /* - * This schedule_timeout_*() serves as a guaranteed sleep for - * PF_WQ_WORKER threads when __zone_watermark_ok() == false. - */ - if (!tsk_is_oom_victim(current)) - schedule_timeout_uninterruptible(1); goto retry; }