Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2899803pxb; Tue, 21 Sep 2021 10:00:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO2JYKpGVx5ifvhfYGm5CjF+wpfkaLC91ag9e8mrnFS5X8Dmo0bM9ZcseTSB7hyPT+/ijc X-Received: by 2002:a02:3b1b:: with SMTP id c27mr845127jaa.103.1632243600711; Tue, 21 Sep 2021 10:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632243600; cv=none; d=google.com; s=arc-20160816; b=AT+O75qEV5grdAx2gaedJwsfQkvsOFgeZKnd7Si57EDeQhhQYRlSeGM+t+sho1lvr8 QPM7LfnGk8oFrdyf/SBxJ98CMNBROdRhz6MCqc7Ouu58INfIvbtvAZeO1VFfMuoNBaOK P9MDISVG2ygCSmnL0OarPdEaY2PomBGOJe6M6L2fvJ90h2/lIeui1Lk9PSq3NWsoUoEY ZEPRkKiXVtXtZj6ShR41rjHWS/jPJVn0GPXrcK8TQvtuy1OBWTX0HhSWpG3BUn6RkRTS rxfZ266qHl5AoUmXxQle6gGug9A1ozgnztGNx7KC3pPfgsL6bhUa7CIBgZAX6JMdRTUd jx2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=UKEwcbJEyUP0PqyzuU1jDgKq63XLBjLh4Ta6kc0XTvE=; b=wAQcO/bgo59FgZjwTjTOgxtpa6SVac18AV8MZhjlyOdyqIfHDzvfOCX3140tOPp4dy 2hSHQYojzfAp1BhS7Vhn2j9rz9DhWBuyUu5XKT8foYMDs1iXP3/l0Tjpb4lKpKmbbyRl HKHzskFLQk56P0jhtiDHiVOZrhdfijLel+qMeHAnQt9Ym599+FaFhrNKrc3SRqNgJWhy RM3+bJ+n5x87UALQGqo3aoebXvgqWmg9L8rY/Xzhf+a4g1X8irvz0f0pYDUOtVB9NeVw vbGhpRNbIDYl+GNeoX2pT0SiMX87gWmS1U4X8p6te1jK5WcwtpeCiNHuPQb9xwGbMVL2 xRlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PUqZB0dL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si3842874ili.126.2021.09.21.09.59.48; Tue, 21 Sep 2021 10:00:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PUqZB0dL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbhIURAJ (ORCPT + 99 others); Tue, 21 Sep 2021 13:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbhIURAI (ORCPT ); Tue, 21 Sep 2021 13:00:08 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F05F4C061574 for ; Tue, 21 Sep 2021 09:58:39 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id g14so85945pfm.1 for ; Tue, 21 Sep 2021 09:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UKEwcbJEyUP0PqyzuU1jDgKq63XLBjLh4Ta6kc0XTvE=; b=PUqZB0dLwluGdzZQ4zV6cjuxUbh0c2kg+B3SeVT/lrJ1XbYCAhKV1VZtrAdLXONOxW nUcSGGIpjRpDvyVsZZDn4irjNUynHXB4c3UNObGKO95LknN+ZmW45CfUsc06Dm6+//kM OWnstcShvsSnaXvXOzSiKaw+XfhxnsKo9DnQp8+THp5oY8z0AvLBMgqUGGUmxikPJ69C DpdA591UCBC4s6bvd6HNkrHdzcReEk3jeJR5Jw91cBAwjpDMGjikq93/DJ3pLoQiCj9o fGpIbX+H1/o9R0yhAIyIiW15ycbzc5feAFJXQOfLzeQg0UorYhHbmKOz5f51Vt5HoYAg JQlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=UKEwcbJEyUP0PqyzuU1jDgKq63XLBjLh4Ta6kc0XTvE=; b=jizNvjnOEydIK9Q93E7fj5Ge63RnOfSfEEePZyhnyF3bSHiwM48HB2bRrV6wWOC+42 FdVx4F5uqyqsNZAk6BB23mUl2gX0jzYaueJOYGI7/0jzM4ghBuu2KbOG6WSWXtHqgZR5 lQvltJyI3De0fC2iq3FpliAuIgJ/g9AUydpVuHeZDjqdynNrYcjmTSA0voWysV7wM3RR mJBkWgUauw3OqSRjZNgGDkbYk6TaxSMFEdCMFPjmJ4bn/XfJDQhPXn4wf3VWQeiIfrzm mnvPf6J7gUKCh4ZGQW3QToWGvIFbGoUAo2Uud8Qt5RJMbzu/nxkqF7hvP0rYXIxBuSsb z5Yw== X-Gm-Message-State: AOAM532izuZB1tVvXNBiPAsCN3FlLi69I3QaDBHvafQgGvlqVPmV8kJx zxdspageuUssghJsMBWC2XyBlbYkvlw= X-Received: by 2002:aa7:97b2:0:b0:439:14a9:2bf5 with SMTP id d18-20020aa797b2000000b0043914a92bf5mr31535117pfq.45.1632243519433; Tue, 21 Sep 2021 09:58:39 -0700 (PDT) Received: from sultan-box.localdomain ([204.152.215.247]) by smtp.gmail.com with ESMTPSA id h6sm18237584pfr.121.2021.09.21.09.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 09:58:39 -0700 (PDT) Sender: Sultan Alsawaf From: Sultan Alsawaf X-Google-Original-From: Sultan Alsawaf To: sultan@kerneltoast.com Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mgorman@suse.de, mhocko@suse.com, rientjes@google.com Subject: [PATCH v2] mm: Mark the OOM reaper thread as freezable Date: Tue, 21 Sep 2021 09:57:58 -0700 Message-Id: <20210921165758.6154-1-sultan@kerneltoast.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210918233920.9174-1-sultan@kerneltoast.com> References: <20210918233920.9174-1-sultan@kerneltoast.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sultan Alsawaf The OOM reaper alters user address space which might theoretically alter the snapshot if reaping is allowed to happen after the freezer quiescent state. To this end, the reaper kthread uses wait_event_freezable() while waiting for any work so that it cannot run while the system freezes. However, the current implementation doesn't respect the freezer because all kernel threads are created with the PF_NOFREEZE flag, so they are automatically excluded from freezing operations. This means that the OOM reaper can race with system snapshotting if it has work to do while the system is being frozen. Fix this by adding a set_freezable() call which will clear the PF_NOFREEZE flag and thus make the OOM reaper visible to the freezer. Please note that the OOM reaper altering the snapshot this way is mostly a theoretical concern and has not been observed in practice. Fixes: aac453635549 ("mm, oom: introduce oom reaper") Signed-off-by: Sultan Alsawaf Acked-by: Michal Hocko --- mm/oom_kill.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 831340e7ad8b..46a742b57735 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -641,6 +641,8 @@ static void oom_reap_task(struct task_struct *tsk) static int oom_reaper(void *unused) { + set_freezable(); + while (true) { struct task_struct *tsk = NULL; -- 2.33.0