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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 01B74C433DB for ; Mon, 22 Mar 2021 20:43:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2FD316198C for ; Mon, 22 Mar 2021 20:43:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FD316198C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7F1CA6B010A; Mon, 22 Mar 2021 16:43:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A2006B010C; Mon, 22 Mar 2021 16:43:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 643496B010D; Mon, 22 Mar 2021 16:43:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 47C296B010A for ; Mon, 22 Mar 2021 16:43:44 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 08B703A9B for ; Mon, 22 Mar 2021 20:43:44 +0000 (UTC) X-FDA: 77948686368.03.8B67067 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf08.hostedemail.com (Postfix) with ESMTP id F2999801A808 for ; Mon, 22 Mar 2021 20:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=Zjw6xHblWwTqInlnqr5esznSG2yRgKtw4cpscwnNITo=; b=OGCKIv7xBGkVve8+JeTApeYnvj 3wbmkIqmwFsp3pPdWegP8YPwKY7C/Sc9zG/8ncUNvh9P0laRSC9tvS+O2DiWsx/CmG/8v908i5+bj 5/hdhY5wYM5slJzaY/W5TzCMguAeIdIqFFl1UfChi155LO/q5JIJSR09tGLm7sn0mygyM3R7ARn2M j419ArRW2wUZfgnpbil+6iVSMKCijNLGYpb/O56SvUaP0U1BB92Ct57jjSgG+uitNgwfewnYN4e1c n7/Gj+dYkL2Vgk3O6zAir1eynHCFuP/3pTpQbggH5fRCVGkfPyWr8bljXjBGUhZbcAcZVmYzaGaQR 8UZ35FTw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lOROA-00CWug-ME; Mon, 22 Mar 2021 20:43:06 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 5A36C304BAE; Mon, 22 Mar 2021 21:43:00 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 30BB32BEF6765; Mon, 22 Mar 2021 21:43:00 +0100 (CET) Date: Mon, 22 Mar 2021 21:43:00 +0100 From: Peter Zijlstra To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , Shakeel Butt , Oscar Salvador , David Hildenbrand , Muchun Song , David Rientjes , Miaohe Lin , Matthew Wilcox , HORIGUCHI NAOYA , "Aneesh Kumar K . V" , Waiman Long , Peter Xu , Mina Almasry , Andrew Morton , Roman Gushchin , Christoph Hellwig Subject: Re: [RFC PATCH 7/8] hugetlb: add update_and_free_page_no_sleep for irq context Message-ID: References: <20210319224209.150047-1-mike.kravetz@oracle.com> <20210319224209.150047-8-mike.kravetz@oracle.com> <2383057a-29dc-383b-720f-7cdcdd015e40@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2383057a-29dc-383b-720f-7cdcdd015e40@oracle.com> X-Stat-Signature: xhcxegzt83gtbxmc4cny8qym5h1eo5bz X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: F2999801A808 Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=desiato.infradead.org; client-ip=90.155.92.199 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616445806-965015 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, Mar 22, 2021 at 10:42:23AM -0700, Mike Kravetz wrote: > Cc: Roman, Christoph > > On 3/22/21 1:41 AM, Peter Zijlstra wrote: > > On Fri, Mar 19, 2021 at 03:42:08PM -0700, Mike Kravetz wrote: > >> The locks acquired in free_huge_page are irq safe. However, in certain > >> circumstances the routine update_and_free_page could sleep. Since > >> free_huge_page can be called from any context, it can not sleep. > >> > >> Use a waitqueue to defer freeing of pages if the operation may sleep. A > >> new routine update_and_free_page_no_sleep provides this functionality > >> and is only called from free_huge_page. > >> > >> Note that any 'pages' sent to the workqueue for deferred freeing have > >> already been removed from the hugetlb subsystem. What is actually > >> deferred is returning those base pages to the low level allocator. > > > > So maybe I'm stupid, but why do you need that work in hugetlb? Afaict it > > should be in cma_release(). > > My thinking (which could be totally wrong) is that cma_release makes no > claims about calling context. From the code, it is pretty clear that it > can only be called from task context with no locks held. Although, > there could be code incorrectly calling it today hugetlb does. Since > hugetlb is the only code with this new requirement, it should do the > work. > > Wait!!! That made me remember something. > Roman had code to create a non-blocking version of cma_release(). > https://lore.kernel.org/linux-mm/20201022225308.2927890-1-guro@fb.com/ > > There were no objections, and Christoph even thought there may be > problems with callers of dma_free_contiguous. > > Perhaps, we should just move forward with Roman's patches to create > cma_release_nowait() and avoid this workqueue stuff? Ha!, that basically does as I suggested. Using that page is unfortunate in that it will destroy the contig range for allocations until the work happens, but I'm not sure I see a nice alternative.