Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5278012rwb; Mon, 21 Nov 2022 20:02:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf5QfcnwojKSWzKtpS6g5v6KJCdagdjq44nDp3n0EGOyXqKWl9pBksypuSnWx9qkjJtjAdIo X-Received: by 2002:a63:e907:0:b0:477:5e25:baf4 with SMTP id i7-20020a63e907000000b004775e25baf4mr9480272pgh.544.1669089775860; Mon, 21 Nov 2022 20:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669089775; cv=none; d=google.com; s=arc-20160816; b=NRolJ2bXYydls3RgjV0a6UQDv7+IAlvRlZArb3iVyV7i8OGOoZcr8oEKVuQGXGJUUN xHgY2aiAMH93lV1ZcVu0xCM1X+pLAllFNJLU8P3VajaT10xL3FohxNRW1BvZKvjxquQQ 1NU6ZWfT8Saz1zCr1C47c69ywqVU/m7D3RN9BVArohO65SI9U5rQ947WdMiMGNiw3viJ k9qCP9++qVmB9GHP1OLvsyM60xCsfGZ339VFdvLWNZUwv8J37FPnr1LLv4YNj3KYeV2q yLbrBIGZr/ogcm4Y9VfvCku8WkHG6u7ambLKbPg4GKWub2qthfWDiW0My7A6mBGKjUpM g0LA== 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=S5oDlArRtMmw99urVyDNSpVN62izNr9i9C2sCE4fBF0=; b=k3aZbbpW39UHE3EfhowdvUshb9NUUvXz2ohOiav3YPEIrnozu+u3bxAxhvQAd9yp7H Hpw/iE7lfFl6VCq908oMJ4EMWIIUU7TnbiryYR3fLPUKC+BiJXVSJoyAk8AJ4ekpTFtY 6Ww68FaTt5KHBINWgIhotMsEqRVKn2bVqCl8Iw6EbvwdGooWrgb7D6arFdIjl5nwExzl qaI4FoULh3Q49YL5x7XyBvE9RWFh1QYpFkD98kutR3PN0haalbwTnRMreihpXzWsY16t SoYz6Ry7XBs0zVeb244U44tlvwQUanaUUZ1m0lxBUsPWI0wrLZkMhBOHXNhnzrBHgG67 zkZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GK+ZdDEb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020a631a4b000000b0047761ad8456si6153927pgm.166.2022.11.21.20.02.42; Mon, 21 Nov 2022 20:02:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GK+ZdDEb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231697AbiKVDab (ORCPT + 92 others); Mon, 21 Nov 2022 22:30:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbiKVDa3 (ORCPT ); Mon, 21 Nov 2022 22:30:29 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3A325E94 for ; Mon, 21 Nov 2022 19:30:28 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id b62so13007420pgc.0 for ; Mon, 21 Nov 2022 19:30:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=S5oDlArRtMmw99urVyDNSpVN62izNr9i9C2sCE4fBF0=; b=GK+ZdDEb16GYXHPP2FnOoiF0rXW/dmeHHI2xYmmoVPSDbAzwQbGcWqsm3zmo9XpPke 1BZZN8h3+7ZjDJ+NgpejGPT4UdN5rw4Uxrh9zncpYu49mrJPUI6M6SjnVsKToYv5rV89 XcmIg92sRueqeLyGVvUZUBHPHh9jRuGXMOm9I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=S5oDlArRtMmw99urVyDNSpVN62izNr9i9C2sCE4fBF0=; b=3M/r9MDFUGmsvPTpAoVc4wKxAGP09+KeY7xxY0yB6tVXTI5wQwrT6tortr4BDLoRJ6 xpnprWX3fmwsVxt5F1p+/t/TsvBMTvDmpyfg/+kXH1EAkIKD0gDRGzcFhJolQmoePpmu GpyvgKjJ7k7HQUzYBmrQDC1FNetVfisFK0ea9FEyIgAMa2s/wq1ihd3AycMpX8Oaey4f DhEINuwiNpXaL2tvM3m4lJXTk04dBAFO2dh9Oopwo9xge+tV33Uq+CGjhgZ0FUJDJkgN LXbcK44eMBVvRzDT5fIicCfSOuHqslHGfyN+m5Yt2yBn7hdhuimx4JUZ1zZhJaFNQ6te q0/Q== X-Gm-Message-State: ANoB5plWFs8FByvxcTyZIYK9KS4umEcLVV8ywhDE8BLT7RPf9SBLVJGc 1PsL/mQBUHg/0R518b+90x+MuQ== X-Received: by 2002:a05:6a00:439a:b0:56b:c95f:34dd with SMTP id bt26-20020a056a00439a00b0056bc95f34ddmr2006400pfb.74.1669087827579; Mon, 21 Nov 2022 19:30:27 -0800 (PST) Received: from google.com ([240f:75:7537:3187:e258:71ac:37b7:2d52]) by smtp.gmail.com with ESMTPSA id y16-20020aa78f30000000b0057280487af3sm9279703pfr.203.2022.11.21.19.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 19:30:27 -0800 (PST) Date: Tue, 22 Nov 2022 12:30:22 +0900 From: Sergey Senozhatsky To: Johannes Weiner Cc: Sergey Senozhatsky , Andrew Morton , Seth Jennings , Dan Streetman , Vitaly Wool , Nhat Pham , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] zswap: do not allocate from atomic pool Message-ID: References: <20221122013338.3696079-1-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (22/11/21 22:16), Johannes Weiner wrote: > On Tue, Nov 22, 2022 at 10:33:38AM +0900, Sergey Senozhatsky wrote: > > zswap_frontswap_load() should be called from preemptible > > context (we even call mutex_lock() there) and it does not > > look like we need to do GFP_ATOMIC allocaion for temp > > buffer there. Use GFP_KERNEL instead. > > > > Signed-off-by: Sergey Senozhatsky > > --- > > mm/zswap.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/zswap.c b/mm/zswap.c > > index 2d69c1d678fe..f6c89049cf70 100644 > > --- a/mm/zswap.c > > +++ b/mm/zswap.c > > @@ -1314,7 +1314,7 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset, > > } > > > > if (!zpool_can_sleep_mapped(entry->pool->zpool)) { > > - tmp = kmalloc(entry->length, GFP_ATOMIC); > > + tmp = kmalloc(entry->length, GFP_KERNEL); > > There is another one in zswap_writeback_entry() that seems equally > arbitrary. They came in through the same commit, with no further > explanation as to this choice. Do you want to pick that up too? Yup, you patch it in https://lore.kernel.org/lkml/20221119001536.2086599-2-nphamcs@gmail.com/ and I guess it's there just by accident. We probably want a separate patch instead that touches those GFP_ATOMIC allocations in both places. So I have it like this at present --- From 66e4acffc0926498f818d11f2f57b9c772131f6e Mon Sep 17 00:00:00 2001 From: Sergey Senozhatsky Date: Tue, 22 Nov 2022 10:26:13 +0900 Subject: [PATCH] zswap: do not allocate from atomic pool zswap_frontswap_load() should be called from preemptible context (we even call mutex_lock() there) and it does not look like we need to do GFP_ATOMIC allocaion for temp buffer. The same applies to zswap_writeback_entry(). Use GFP_KERNEL for temporary buffer allocation in both cases. Signed-off-by: Johannes Weiner Signed-off-by: Nhat Pham Signed-off-by: Sergey Senozhatsky --- mm/zpool.c | 7 +++++++ mm/zswap.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mm/zpool.c b/mm/zpool.c index 68facc193496..f46c0d5e766c 100644 --- a/mm/zpool.c +++ b/mm/zpool.c @@ -387,6 +387,13 @@ bool zpool_evictable(struct zpool *zpool) * zpool_can_sleep_mapped - Test if zpool can sleep when do mapped. * @zpool: The zpool to test * + * Some allocators enter non-preemptible context in ->map() callback (e.g. + * disable pagefaults) and exit that context in ->unmap(), which limits what + * we can do with the mapped object. For instance, we cannot wait for + * asynchronous crypto API to decompress such an object or take mutexes + * since those will call into the scheduler. This function tells us whether + * we use such an allocator. + * * Returns: true if zpool can sleep; false otherwise. */ bool zpool_can_sleep_mapped(struct zpool *zpool) diff --git a/mm/zswap.c b/mm/zswap.c index 2d48fd59cc7a..3019f0bde194 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -958,7 +958,7 @@ static int zswap_writeback_entry(struct zpool *pool, unsigned long handle) }; if (!zpool_can_sleep_mapped(pool)) { - tmp = kmalloc(PAGE_SIZE, GFP_ATOMIC); + tmp = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!tmp) return -ENOMEM; } @@ -1311,7 +1311,7 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset, } if (!zpool_can_sleep_mapped(entry->pool->zpool)) { - tmp = kmalloc(entry->length, GFP_ATOMIC); + tmp = kmalloc(entry->length, GFP_KERNEL); if (!tmp) { ret = -ENOMEM; goto freeentry; -- 2.38.1.584.g0f3c55d4c2-goog