Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1601672pxb; Fri, 22 Oct 2021 04:18:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5qmIw3g0ZfzBz+x7XU8EGF8HjEmtX8TYfcov2GZk5p8Iri6HMbVzqwRWirNd6CxIjWW1T X-Received: by 2002:a17:90b:4ad2:: with SMTP id mh18mr13512070pjb.18.1634901499858; Fri, 22 Oct 2021 04:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634901499; cv=none; d=google.com; s=arc-20160816; b=TyHxgfIyvVt7G694Eqhn5/n4O2SE+ZfWJVdSlOsXReiebT8HdWut495KQGmnbPIuIQ 1sH4s9wKgY+kNZLshsG1qevTUMdXahLvNYMqdMO984vc/69v7ZSJ6pdxf5VjN5bmfQqI lujqkE/4sVyrAkzit3hJHUh3pcSMFOIDXjqx9vW19eoBroBJz7bRWe92St8wwON4jsPB Zwbxy5E607qDZeiO+oBYM5uMeLluXzz2eNQKxxdSFuHUmCtGeCoaQI2o6WVZIXyQTGF5 qaULV+ZKtYaZi1hm007GmQfoed1OA20OYf00N6benQx4JK1PNLR4Qa8hgV8VtlfBzpml /4vQ== 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:dkim-signature; bh=j71blNuhZOgX+/cgAj5pKSXOeyCTnqXp4/c8vquRDLs=; b=n1KlC4isVabL2oo8P7tTi4n6TZ7DF9ypXeuhg4zOHWEY3nCFko9YbX2VOdmMfJy224 098OYsDSFBu7thCEYTq8Dtn6rQYQ/nHU1SuIsIFXuiRVjzFfvPUO/fplbS3xdDcv0/Gz xms2dYIeOl5qZ+kaDOzu6yn5oBNNOBfVw3E2IQ2e2IImSX9Q2stzlHuhHMaZ9zhzokSy aB/yGf2uLaPwMcJwKzu3u0XV8jPK/SNkDdBbLUxW8XHnlcbWsuJ7gAyZkR1/BovU7AhU pPPiJMJdCkQo07KG0yY70W/CF+N3tAE/4XJNmNnI7mh5gW/uhLBDN6fHC3F3u01fIyem QbNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=YGQJcluz; 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 s38si12156443pfg.71.2021.10.22.04.18.05; Fri, 22 Oct 2021 04:18:19 -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=@infradead.org header.s=casper.20170209 header.b=YGQJcluz; 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 S232670AbhJVLTI (ORCPT + 99 others); Fri, 22 Oct 2021 07:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232539AbhJVLTH (ORCPT ); Fri, 22 Oct 2021 07:19:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C568C061766 for ; Fri, 22 Oct 2021 04:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=j71blNuhZOgX+/cgAj5pKSXOeyCTnqXp4/c8vquRDLs=; b=YGQJcluzDOvsTvrCMCXr4eZ5MS BhPc8iNKXeVEE3JCb8WYseynOwxBsc+mprdRTAMR+C926bc876bLxJ5dZGb3fl0VfiO1xMdBOB8Gm bHnR9iydqms+CjZ7dkGSS1fmWV+38XjkCDd5KAgJLwnKiaNDt2Xl8ZVF7EDMY6ya+wB6KuoiIPAmN u20EGiSICFTSFDSMGe6ZBg0S8reu945elOtwxhtYvRE3lfzJy+zZSliiJBqN2mHHycIiBxh2rudTQ mKCPmApMyk2Q5y+hKE5PGIeJ2xe/eFyq+ta1es3VIQRKXjF+shGWh0lcYe7muFSbK2Fb2cBj2sjbq l9PTSomA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdsW4-00DruN-8E; Fri, 22 Oct 2021 11:15:29 +0000 Date: Fri, 22 Oct 2021 12:15:16 +0100 From: Matthew Wilcox To: Andrea Righi Cc: Andrew Morton , Yang Shi , Minchan Kim , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: fix sleeping copy_huge_page called from atomic context Message-ID: References: <20211022074619.57355-1-andrea.righi@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211022074619.57355-1-andrea.righi@canonical.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 22, 2021 at 09:46:19AM +0200, Andrea Righi wrote: > copy_huge_page() can be called with mapping->private_lock held from > __buffer_migrate_page() -> migrate_page_copy(), so it is not safe to > do a cond_resched() in this context. > > Introduce migrate_page_copy_nowait() and copy_huge_page_nowait() > variants that can be used from an atomic context. I think this is a consequence of THPs being created when they should not be. This is the wrong way to fix this problem; and I suspect it may already be fixed at least in -mm. We should have taken this path: if (!page_has_buffers(page)) return migrate_page(mapping, newpage, page, mode); but since we didn't, we can infer that there's a THP which has buffers (this should never occur). It's the same root cause as the invalidatepage problem, just with a very different signature.