Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2377829pxb; Mon, 20 Sep 2021 20:43:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcCXBy1jJi4r6cG/+ERrLM5sjM41UbM8O9GSPPcTT7OgoVqzxowR2Ki3tbbPF48Z0lF5Vs X-Received: by 2002:a05:6402:16d2:: with SMTP id r18mr21110521edx.363.1632195788735; Mon, 20 Sep 2021 20:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632195788; cv=none; d=google.com; s=arc-20160816; b=LEQidBEgxl/Pt5ubk7s9bHV7tZQ9jL9e0aulx8LePgx83VSfOWzGnusmhtITw8+w+M 8/OHV2dj4va96WR/m4dmO43UQxo4gxd8PErCPepnD+a/8gj29wPaTTNWfiGfRKQ8eHgC ZVfuVoOLJx2hjgsNFel7xZvk4NnjzTtwvnzKp5PzcXjS+tp6RbG4nrEQq364HasMVOk6 wS5ZaLdSECYIYra3U4bvs5By4mmiRaDmpkArCoLHYa+5JxPBboE7+KxJKCQXDfdXI2em Fs0UoCtR7j2F6wr1OVgTRxqSH23W83nBPrZbEXJFmWxXLosHo5tVpG0Zw1/1hrpZCT/A CHXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=MofHaBdRGnwseYgSAsKI1CDQXPPyzkLtR0xxeOwgj8E=; b=0v6fjO+LMkV3hiev1fQFyCSZwbXxwLcX4OjPUtAI7RgZcfcI4IfqQ5x5z7UB5tErRz h/3OejoVJsVcsMco1vgAkXKcRdQ1inVUPKTrdmmP+JEPqkgbCHALS3+UUj5Ky7KWWNCL PKaGZS+cdW+W8zfM3AUu2BJZ1TB0aYuWM3NVm2SfdhLoDXB8sA6IbeX+fcaom4H8JFzw kzxOCpne+EW3h8PA6fSgjqHoINGNvpF9ru+gpcxWESUmWFlJVjHTs2c0iSiPG9MawIrR cjrTgXRApjsARXnu1JrEcvdU4kJa5AUTAxNn2p21pn+4rZSbJyJpgmdKxdb4E/U6SQKJ nzQw== ARC-Authentication-Results: i=1; mx.google.com; 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 k24si6985687edk.120.2021.09.20.20.42.45; Mon, 20 Sep 2021 20:43:08 -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; 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 S237111AbhITWdS (ORCPT + 99 others); Mon, 20 Sep 2021 18:33:18 -0400 Received: from mail-pl1-f172.google.com ([209.85.214.172]:40594 "EHLO mail-pl1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238078AbhITWbR (ORCPT ); Mon, 20 Sep 2021 18:31:17 -0400 Received: by mail-pl1-f172.google.com with SMTP id n18so12028905plp.7 for ; Mon, 20 Sep 2021 15:29:49 -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=MQhMF7zep7yiKbDABdUvx7q7geCQEQYp/09p4aZsgyzxyBvI18kH2bTRDO02r2LDFg CP/KlDKoAC7Le/fILMF/oDrs374nH3CatM/a4gATaXyFKBuyovsswLwHQXY7jp3pQKzM GhOCIPDHWCBsAckwnRonfOjPg1FSqsGn3c/0lkMAa7+D8NWJpYtuSdV3Bx0YNs/920Bv lO4Y9lkf3SimOnKtSF5t5JvAZOQWIaQ0nq4pTldMFWVOHtLLGkjQtnXASx22B2Nybtko 9oTVKGIn7II5NFB/OU31fZc4JzKKlZwPQOsC1669A6YSDiMzyNDz4Hd9RYXteSBmg6uM Ab5Q== X-Gm-Message-State: AOAM533LI/3Um+ioCL5SJSNW4VsEWQ8GtjpiFx76V6ndMOf1OCMS68y5 Mxvf63TQQIgubm4YJ4YA3Fs= 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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