From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 621EAC433EF for ; Mon, 20 Sep 2021 22:29:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E0CB760ED7 for ; Mon, 20 Sep 2021 22:29:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E0CB760ED7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kerneltoast.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3D56A900002; Mon, 20 Sep 2021 18:29:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 383C26B0074; Mon, 20 Sep 2021 18:29:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24C7D900002; Mon, 20 Sep 2021 18:29:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id 121426B0073 for ; Mon, 20 Sep 2021 18:29:51 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BF5D8180E1CEB for ; Mon, 20 Sep 2021 22:29:50 +0000 (UTC) X-FDA: 78609395340.05.BE90A51 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf04.hostedemail.com (Postfix) with ESMTP id 7AEF650000A8 for ; Mon, 20 Sep 2021 22:29:50 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id g13-20020a17090a3c8d00b00196286963b9so525649pjc.3 for ; Mon, 20 Sep 2021 15:29:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MofHaBdRGnwseYgSAsKI1CDQXPPyzkLtR0xxeOwgj8E=; b=lF1zNJ79xQ0cooN8mgY/lyVgemTUBJZzt6EBbEc0qwQujHnF6AwsE058ocMJ6PsT9D JLXrTufdClaZniV0VP8nLKd8jXPG9/8RMqIYLf39+tgZNJvdHzdCOau3ovW+aAe0C3ko zmJvMQnTi/muH2E1p6zV9v7jpUMv5QKOgx3Tc9VpgnzPjr46ixEMCRrR9ClqfAG8cI8N tAXTf7N3Go/oqz1Z3L9gMwkNG6YYhWaXopYwmZxV5sUiqv9D9HG7jTSySE+DhBXOyDN4 nyHAqcikSjzFCpFv3Pf1rt1MXR5HIb3QoBkUou0LMwxoZmC3F6u3v9R6pmgSxBCtZEiG 80vA== X-Gm-Message-State: AOAM532QFbU5F3BItLAQrL6IURf3p6YR4Ii2b5GWbAAc/mSL0BLj0Fdy gU8VgDAvDOLHRxmE/iHIIbw= X-Google-Smtp-Source: ABdhPJywX2Nx36bpG9Miqst8Bbp3rSetU1+dy7FuO4oGjYkUzFhVXOZw9nglgJF6uVNiIyMaMH4Ihw== X-Received: by 2002:a17:902:cacb:b0:13a:5f28:e4cb with SMTP id y11-20020a170902cacb00b0013a5f28e4cbmr24833661pld.37.1632176989573; Mon, 20 Sep 2021 15:29:49 -0700 (PDT) Received: from sultan-box.localdomain ([204.152.215.247]) by smtp.gmail.com with ESMTPSA id q18sm15490909pfj.46.2021.09.20.15.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Sep 2021 15:29:49 -0700 (PDT) Date: Mon, 20 Sep 2021 15:29:46 -0700 From: Sultan Alsawaf To: Michal Hocko Cc: Andrew Morton , David Rientjes , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: Mark the OOM reaper thread as freezable Message-ID: References: <20210918233920.9174-1-sultan@kerneltoast.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf04.hostedemail.com: domain of sultan.kerneltoast@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=sultan.kerneltoast@gmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7AEF650000A8 X-Stat-Signature: q6x46pa7ayi8jin67tsbz3srmhiduw4w X-HE-Tag: 1632176990-706217 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: On Mon, Sep 20, 2021 at 10:30:12PM +0200, Michal Hocko wrote: > We usually tend to provide Fixes where there has been something fixed. > It seems just confusing if it is used for non functional changes, > cleanups etc. Thera are gray zones of course. Got it, thanks. So no tag would be used in such a case? > I am not sure I follow. My understanding is that we need to make sure > oom_reaper is not running after the quiescent state as it is changing > user space address space. For that I believe we need to freeze the > kthread at a proper moment. That is currently the entry point and maybe > we can extend that even to the reaping loop but I haven't really > explored that. PF_FREEZER_SKIP would skip over the reaper and that could > result in it racing with the snapshotting no? Kthreads cannot be implicitly frozen; it's not like PREEMPT. From what I've read in the freezer code, two things must occur for a kthread to freeze: the kthread must have PF_NOFREEZE unset (via set_freezable(), as is done in the patch I've submitted here), and the kthread must have an explicit call into the freezer, such as via wait_event_freezable(). Right now, oom_reaper is totally ignored by the freezer because PF_NOFREEZE is set by default in all kthreads. As such, oom_reaper can keep running while system-wide freezing occurs. If you think this can mangle snapshots, then perhaps there is a real bug here after all. It sounds like you don't want oom_reaper to slow down system-wide freezing, but at the same time, you want oom_reaper to participate in system-wide freezing? I'm not sure how you could achieve that, aside from maybe inserting a call into the freezer while iterating through each vma, akin to adding a cond_resched(). My PF_FREEZER_SKIP suggestion was just to emphasize that oom_reaper is currently skipping the freezer anyway due to PF_NOFREEZE, and that you could set PF_FREEZER_SKIP to make it skip the freezer a little faster if you wanted. > Is this something to really worry about? I'm trying to emphasize that the current usage of wait_event_freezable() in oom_repear behaves *exactly* like wait_event_interruptible() but with some extra overhead. Sultan