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 468D9C433C1 for ; Tue, 23 Mar 2021 12:04:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C536D61994 for ; Tue, 23 Mar 2021 12:04:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C536D61994 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 195436E8CE; Tue, 23 Mar 2021 12:04:12 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 530C56E8CE; Tue, 23 Mar 2021 12:04:10 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1616501049; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hlDvHobKzx0p3BSIH1iU7GaUAE5bHJz9NOdKDiruEDw=; b=JJdQSwDPmNu+V+SFxAJz0cPaoRDt9+YJVooaeTdADIzQtvY2KJCZpaE2tXGKWGNSnSEAWd zvILv2OrSuG9HDHAaaYqWPzTo6gVgGKgUPDHYccFUkocI7EgIcKKwG+x7B9sVu0LOHcAGt zASxfaswP7AZmwCpPzsp3jmdlxBiQJk= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E06ACAD38; Tue, 23 Mar 2021 12:04:08 +0000 (UTC) Date: Tue, 23 Mar 2021 13:04:03 +0100 From: Michal Hocko To: Christian =?iso-8859-1?Q?K=F6nig?= Subject: Re: [PATCH] drm/ttm: stop warning on TT shrinker failure Message-ID: References: <20210322140548.GN1719932@casper.infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Wilcox , amd-gfx list , Linux MM , dri-devel , Dave Chinner , Leo Liu Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue 23-03-21 12:48:58, Christian K=F6nig wrote: > Am 23.03.21 um 12:28 schrieb Daniel Vetter: > > On Tue, Mar 23, 2021 at 08:38:33AM +0100, Michal Hocko wrote: > > > On Mon 22-03-21 20:34:25, Christian K=F6nig wrote: [...] > > > > My only concern is that if I could rely on memalloc_no* being used = we could > > > > optimize this quite a bit further. > > > Yes you can use the scope API and you will be guaranteed that _any_ > > > allocation from the enclosed context will inherit GFP_NO* semantic. > = > The question is if this is also guaranteed the other way around? > = > In other words if somebody calls get_free_page(GFP_NOFS) are the context > flags set as well? gfp mask is always restricted in the page allocator. So say you have noio scope context and call get_free_page/kmalloc(GFP_NOFS) then the scope would restrict the allocation flags to GFP_NOIO (aka drop __GFP_IO). For further details, have a look at current_gfp_context and its callers. Does this answer your question? > > > I think this is where I don't get yet what Christian tries to do: We > > > really shouldn't do different tricks and calling contexts between dir= ect > > > reclaim and kswapd reclaim. Otherwise very hard to track down bugs are > > > pretty much guaranteed. So whether we use explicit gfp flags or the > > > context apis, result is exactly the same. > = > Ok let us recap what TTMs TT shrinker does here: > = > 1. We got memory which is not swapable because it might be accessed by the > GPU at any time. > 2. Make sure the memory is not accessed by the GPU and driver need to gra= b a > lock before they can make it accessible again. > 3. Allocate a shmem file and copy over the not swapable pages. This is quite tricky because the shrinker operates in the PF_MEMALLOC context so such an allocation would be allowed to completely deplete memory unless you explicitly mark that context as __GFP_NOMEMALLOC. Also note that if the allocation cannot succeed it will not trigger reclaim again because you are already called from the reclaim context. > 4. Free the not swapable/reclaimable pages. > = > The pages we got from the shmem file are easily swapable to disk after the > copy is completed. But only if IO is not already blocked because the > shrinker was called from an allocation restricted by GFP_NOFS or GFP_NOIO. Sorry for being dense here but I still do not follow the actual problem (well, except for the above mentioned one). Is the sole point of this to emulate a GFP_NO* allocation context and see how shrinker behaves? = -- = Michal Hocko SUSE Labs _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel