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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0279C4332F for ; Tue, 22 Nov 2022 03:30:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50D586B0075; Mon, 21 Nov 2022 22:30:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 496688E0003; Mon, 21 Nov 2022 22:30:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35E938E0002; Mon, 21 Nov 2022 22:30:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 287B36B0075 for ; Mon, 21 Nov 2022 22:30:31 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EC2BA1C668B for ; Tue, 22 Nov 2022 03:30:30 +0000 (UTC) X-FDA: 80159650620.25.C2518A3 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf15.hostedemail.com (Postfix) with ESMTP id 85C34A000F for ; Tue, 22 Nov 2022 03:30:28 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id 62so12912410pgb.13 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=O0IdPwDHui4evETNqG226w63jfDOaQxYzZMX7jW5YH9dC8jyRX631C4srzTHm5HVO0 8hyQLwQYPKI7OIerKybsI1EAUGeNb/+uYK9u6qRiz5+nDHObK8bDUDrQ0l8j6QA1cThD XnCtTYC824Mum3KTaLPd2tgrbAKo98Dsrg9Du3D+bJNszKmte91d09TwEHgvYjw/+G8Q saNPL5tBEPxystDOt/jM/5jpPg9ctV6qr7VzD+2mR/9iIhUsaa9xqt7sLr3C6I7OxKYY Iz09WMd68soKDW7CBgR3fku8Iz52mh/PLfi85orQwD2Nkfz+zDESW223rKGwPf+qlXx+ N0UA== X-Gm-Message-State: ANoB5pm8zI7NXSSu27OhLdDC7ZUZL7u5mQnbw0F1yBTBItex/rF7W0zu 5oemlO8g6imVwaic3LXeietC7g== X-Google-Smtp-Source: AA0mqf4VZRRZaWCn9No0pC1Jg+R9MBk28gho9viR3o3LSoSprNWTLt4wSzhaPrqz2vt0oShWyP/Y1A== 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: ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=GK+ZdDEb; spf=pass (imf15.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.179 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669087828; a=rsa-sha256; cv=none; b=gxHm3D8f3/KnYCqubUBZqE16WnltiZ7lOEZIpNhdx6B8O4cVgJh6isYN5DBcxVFsOZOKpY qZvU1m6YGZCFq+Bby3ZoWqSCfNeEETbVtLid7FRebIfdThq9O9wXMubdej0nm+ZVVgQkEj DqGnM9yrf1jUQiLJNe9r9CxS4rHp+Mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669087828; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=S5oDlArRtMmw99urVyDNSpVN62izNr9i9C2sCE4fBF0=; b=4oZcjrehGi7N/xscytOFnhaUYiMuGC/1IUiAivDzAFgYAOiWCBop3MrIXXa+D5wHyEHvuD JbzYdwf8/zjcnrNhTbSE+u760iKiYcsft9RwU2o3p4MZSdIF2W4iMB39jvBIoiEvlqVkZf sDqm0gJ2EFPBVgonDqioy9QZDZeQyeY= X-Stat-Signature: d13kzqegwn19wokdrai3irrpjssxxw3q X-Rspamd-Server: rspam08 X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=GK+ZdDEb; spf=pass (imf15.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.179 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Queue-Id: 85C34A000F X-HE-Tag: 1669087828-431105 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 (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