Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3256162pxf; Mon, 22 Mar 2021 01:43:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDBAbCc0o1cw2R/V2jfyHzsM8KY9uHTI3l5QYQwOvpgRKLMheFnlGSc4eqEQ2M6L65T+OL X-Received: by 2002:a17:906:7f84:: with SMTP id f4mr17783480ejr.525.1616402587775; Mon, 22 Mar 2021 01:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616402587; cv=none; d=google.com; s=arc-20160816; b=XpWZUD0xCZEXSVbrn1KdokMp2Gc4oDsIQU2wuLgBJkjR8QKMuMFES+2W+JOqUQyOli 3tsk+cKrO2KGdslYlY7JHjBX5QimqIe4aXCW8uSKV5OPHuyTS3+gJemsLHf7bOxqTBND F4xhTxOOWWorfh3bSau+rjGkbWTgH4fe3lm4CCRYguW7SMmyjr23SUsSOfXYmSBwf6Bw Am+aqloqDuJqUYFd1z8UM8sgX2u8E/C+r1O4BMLyhRf7kseaNRuD1nOxHOUEP2poJURS qtTZTDKJcy8NEmlmW3SQ+pQxAAajmhZSpFpJCH4ILxAsAfx+zN0O9wB/x+j3bbQ36TSR aA7g== 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=11+UFgsBMO5aIIt0nyFMZFMoj2kZkZa2BFIWC1a/WoM=; b=BtTbHUP302Sr2rRp+tP3+2F/ZUQhK9/DVv2+e20IuYe9mQ0fGrAN0NLeLBsI1Vb2rq qb1Fa1O89uO7mre1iubqaqM7Ciy9z73d5ckeNu7qdVi1XmGegqkIMxfT4IjUU2aGTRTk RhjFJFgQfLpmM+eJ4JrzgqgYko1mtn0HEfnbZ4wV3G+phc0Q54fsXHj9qeRf868z5PVI MK2j6P2b6MIrt0lZc+9a/5Alap0iCwQkoWn1CeT2pwbj9k+cSwFM4Qose/nAS4AInWID eQC5zwDUOOc4+npZQTUA5awok2OFlxV6YAGbLyVlDLTbC7Qv6EIXpDEOWbPfL3TirGfD HnzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=lV8HIkXz; 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 m12si10710126ejx.720.2021.03.22.01.42.45; Mon, 22 Mar 2021 01:43:07 -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=desiato.20200630 header.b=lV8HIkXz; 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 S229692AbhCVIlv (ORCPT + 99 others); Mon, 22 Mar 2021 04:41:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229822AbhCVIlf (ORCPT ); Mon, 22 Mar 2021 04:41:35 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0FC3C061574 for ; Mon, 22 Mar 2021 01:41:34 -0700 (PDT) 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=11+UFgsBMO5aIIt0nyFMZFMoj2kZkZa2BFIWC1a/WoM=; b=lV8HIkXzu0t34CZyUyWjYUlW1B p91isxG3kwk5Bp3ePNYJJohdUvAsHlifP2q3uAK4GHOLjPo3MVVgSEX60wHv4WCZrlg+MyKtEQ7rN S3UCYNKBoivSNroKkqQY2QT4eoP+D/0FfoDM9EE4q1qKgi9umPBtU4AKnZ6RZ5AUeZJMeZT4BihaX 9Q6ebwb7mU/ckMvLohB2zVYNNii3S1jdJfW5iHQOnA6MD81ZIf31Hn3jneezHCgmW8+84LZtV/WPs 9smOMK1kWXdDHMtTf3+QZAvRsNNFOv5dOsjqf1ruzuv6JbNlTJtozfDKGyHa8SSzW5OgnQi59OpR8 nbMqtWGQ==; 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 1lOG7S-00BC0d-ND; Mon, 22 Mar 2021 08:41:03 +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 58B8E30377D; Mon, 22 Mar 2021 09:41:01 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1FDCE2CE3915C; Mon, 22 Mar 2021 09:41:01 +0100 (CET) Date: Mon, 22 Mar 2021 09:41:01 +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 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210319224209.150047-8-mike.kravetz@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Also, afaict cma_release() does free_contig_range() *first*, and then does the 'difficult' bits. So how about you re-order free_gigantic_page() a bit to make it unconditionally do free_contig_range() and *then* call into CMA, which can then do a workqueue thingy if it feels like it. That way none of the hugetlb accounting is delayed, and only CMA gets to suffer.