From patchwork Wed Dec 18 06:34:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13913090 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 02E13E77183 for ; Wed, 18 Dec 2024 06:35:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A46C6B009B; Wed, 18 Dec 2024 01:35:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 652EA6B009C; Wed, 18 Dec 2024 01:35:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51CC46B009D; Wed, 18 Dec 2024 01:35:50 -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 30DCA6B009B for ; Wed, 18 Dec 2024 01:35:50 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E1F02160BDB for ; Wed, 18 Dec 2024 06:35:49 +0000 (UTC) X-FDA: 82907118336.12.D69D700 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf15.hostedemail.com (Postfix) with ESMTP id 4075FA0008 for ; Wed, 18 Dec 2024 06:35:02 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Y/QgStrj"; spf=pass (imf15.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.181 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734503715; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=06dLgy7e/21/5Xh2W7aoiU59dLBqGpGpJ1upbma1LzU=; b=zp1AOQwJA0dm0Ao/Zo0XbrTGFPiHLivHvMrg0YdtjdWSdgWpQTnOxH9gne9dKozn2oscpI Rf9FEl5uMZsoSWtCp/SoFTKZZi1N92Znvubihy/3Tw+tniN1zuKkVskQbgAPMF6WIANQZI 9kRkkISNzabbxxUxP+rQJddvwbn6p4A= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Y/QgStrj"; spf=pass (imf15.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.181 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=1734503715; a=rsa-sha256; cv=none; b=Ueu4eWznAWKJodNrgNZcCrx0BjRoXVpRWYdOPe2GsijbxBy4xkgvpTjGkVN+cHQxBfdil6 RZCTP7Shm7w+MV7H+xtvEBorEGLESc6FFe82L/QPcW8a82z4W/jpiL7PArF/tZMvKXGu2p 9FQfnOjoKEOgFrbtVlZQvL02tVlnzYQ= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-725e71a11f7so320164b3a.1 for ; Tue, 17 Dec 2024 22:35:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1734503747; x=1735108547; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=06dLgy7e/21/5Xh2W7aoiU59dLBqGpGpJ1upbma1LzU=; b=Y/QgStrja9OJ6iAAC9BU0067zf8VMaVeK7foSDrq5p+hQHJ4lXWG/dzx0RlqCDa/G5 gILuI1U3nwYg0jk2qcznGVahUILbrErrXx6aLlmo3tnkxLri+7XeXQXDQi77lPSb+9Le 2Ur9fktLg8zccPI7AuNdJQquUMInE2dLvcGzM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734503747; x=1735108547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=06dLgy7e/21/5Xh2W7aoiU59dLBqGpGpJ1upbma1LzU=; b=k2LhVApGQntb3/U+3jiAN/sxWPXZIEkbTsHNdy6e5tDzVyPySDKD4o5X/YrEqt5dBm kHhLacyjhYXrLvwM5ob5z0z00Tu2aqG2ME+hkR18A92CVJ7jKg3IaDEIlzzWPwG6Ruco IvYGDxfMnscRnYeDBI2MLoOb7GtTRyTdAqyBWiVGF/oDDv6/gPvpZnWmL+nVdPM0tec4 LOnU5KEAp4MCXeGd3P7zQSDvlNLdVdF1ZsUGICbFp1dQIYi21HpY1QZkN1JrK0vPROae 4aU++vhCNz1bdUfqHTfgKWLBueVaVGq/pGBxnogJHEp0SaYxxa1Uh0OHTqdjimYlzHhd 2xHQ== X-Forwarded-Encrypted: i=1; AJvYcCX8liPNu3wpOyleXukvR7cG9X7vjSVnGbt6cjXdiF9RAgIf8h+Ix2uyNhWGhaAjrz1pbjqHkFfG4Q==@kvack.org X-Gm-Message-State: AOJu0YzV3tOhEcM7+Tgc757HYb/TFoL08Ms0mU0RNMD+w3M9sdBJXimB 7WZU9y34kuimtH6+n41R63z2yXFijDSvr9tUN21oY8hg63UcOx0VWNk4IlbbwQ== X-Gm-Gg: ASbGnctfMA5iMrOU4umw548It9Ovs7bNzlKxWRprZtWyhXVe9d8RXpqUJ2Czs5prOUd 8Cq6GXjs8XUYqheUfPQBGxjWYtB/sR8aQjxdm1aY3fVZs11Wk/e8Jqa3m58uLqMZ7YzpLuGZ3Xd qTBq8l67hfKclwpY2bI+bQ0PSpQsmpEY+CxBG4AI9glj0B7ji0ZJAogJmPEIbV697+vv/vSbPqQ IUsImFLbCRCb+sQoBzGcECIX1xQWcbH/S94G6KtiQehMQSCwbeYhialjco= X-Google-Smtp-Source: AGHT+IGf8g96scNATdGQ6vdl6cixlVJ73v6GuTOkPIuKqnPqyqGhnKzXBehwZAxlCiqlPr2dEdXf8A== X-Received: by 2002:a05:6a20:431b:b0:1e1:aef4:9cd9 with SMTP id adf61e73a8af0-1e5b5a7da91mr2332683637.23.1734503746822; Tue, 17 Dec 2024 22:35:46 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:3bcc:36cc:b9fe:9379]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-72918ad5c07sm8023644b3a.60.2024.12.17.22.35.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Dec 2024 22:35:46 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton Cc: Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv2 7/7] zram: cond_resched() in writeback loop Date: Wed, 18 Dec 2024 15:34:24 +0900 Message-ID: <20241218063513.297475-8-senozhatsky@chromium.org> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20241218063513.297475-1-senozhatsky@chromium.org> References: <20241218063513.297475-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4075FA0008 X-Rspam-User: X-Stat-Signature: et6ga3qhe9hkd8idcqqbpkqpyj818jnw X-HE-Tag: 1734503702-798744 X-HE-Meta: U2FsdGVkX18w+k1PRV+LpHwtH2+M05Dc3pTOvLru0zZOJdcDm1xi9GWItXOqK7M5ZvQwwetRV9Pc/FOSoE/YJD+U73fj82eDNNavKyrnQhpq3Hvp1p9axJAlRgzhRQK5PUfajTbyrI3lK5nHuKnLvyaVTRImWn+VnhvqIRPm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5xF8yo+0PXGadDVxvr7kIey8dOUtZUYiHMY+JZFCboJv4vJwaknAqIAy/Tw== X-Bogosity: Unsure, tests=bogofilter, spamicity=0.486822, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: zram writeback is a costly operation, because every target slot (unless ZRAM_HUGE) is decompressed before it gets written to a backing device. The writeback to a backing device uses submit_bio_wait() which may look like a rescheduling point. However, if the backing device has BD_HAS_SUBMIT_BIO bit set __submit_bio() calls directly disk->fops->submit_bio(bio) on the backing device and so when submit_bio_wait() calls blk_wait_io() the I/O is already done. On such systems we effective end up in a loop for_each (target slot) { decompress(slot) __submit_bio() disk->fops->submit_bio(bio) } Which on PREEMPT_NONE systems triggers watchdogs (since there are no explicit rescheduling points). Add cond_resched() to the zram writeback loop. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 7dd72b58e921..5b8e4f4171ab 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -884,6 +884,8 @@ static ssize_t writeback_store(struct device *dev, next: zram_slot_unlock(zram, index); release_pp_slot(zram, pps); + + cond_resched(); } if (blk_idx)