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 27897C282C6 for ; Mon, 3 Mar 2025 21:55:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BACE6B0089; Mon, 3 Mar 2025 16:55:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76B436B008A; Mon, 3 Mar 2025 16:55:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 632FF6B008C; Mon, 3 Mar 2025 16:55:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 446CC6B0089 for ; Mon, 3 Mar 2025 16:55:32 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E81541610B7 for ; Mon, 3 Mar 2025 21:55:31 +0000 (UTC) X-FDA: 83181596862.27.F315027 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by imf05.hostedemail.com (Postfix) with ESMTP id DCBF810000B for ; Mon, 3 Mar 2025 21:55:29 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=inLfcfKh; spf=pass (imf05.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.170 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741038930; 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=WdrIIP96hB4G69vYpanHuRUgE9nuR/b6P/MWHZpJMKU=; b=YdWaTJRx/glDF7yE5LhixTPxQ7/otZ+QIgxKK2PxsPi5aa2gc0gO+Vb+16VGsR8LVqjQbp XV7bUi3dygnPf3RaMuLg8Dxj1xdtRJPvuoRULiXYHba5OfPqMmGtadjZ7zq30T2XwA05Xu 4Qs2DVb0/epSyFgFH+PbRTH+igvHVe4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=inLfcfKh; spf=pass (imf05.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.170 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741038930; a=rsa-sha256; cv=none; b=aadMV+Io/u7JRET3lu4Qxc9Z72OI8r8Frpu3Q7M10y5pxy+qz9lIgvF7XiR7jfVyf3TDEw Tm9LT26DFMOg8KR04NEG9k84i2n4klpaq0EF1K3oeGkCA+DKXITVjS5p8Eksucyotr6+RV 4gEMgtYvWHCSWKwSZDFSGe+bOgbdH6U= Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-474bc1aaf5fso65981901cf.0 for ; Mon, 03 Mar 2025 13:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1741038929; x=1741643729; darn=kvack.org; 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=WdrIIP96hB4G69vYpanHuRUgE9nuR/b6P/MWHZpJMKU=; b=inLfcfKhG2NbeUe6zB6Nf93v7pV6/QifAfVlwqtWQLkwYTTUckCH6yPFPzt65RRz2O AUm+wWk463EedB9w2X23sLeX61a1o6og+c0wLc/dLIgGocX7kSUakwMdB6LlzV5dmtIO /969HrukeY6n4XiqfAMJUEksVroFrZe3S70UEw53m0trJQSAIm7Uug7TUCK1aHVE9wda TF0ek11VINjC6P/SNMn4zny0REhzbc1S6a27Z5oifppBtvaeLlrYFMgcMvkGexluMneO jVsGtKwQgJjVw4xLL31+A2f+jNHY4irH5jtfdxNSa+Hp1tj6+VXJElqdrCv0ZSSgCwYP rNJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741038929; x=1741643729; 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=WdrIIP96hB4G69vYpanHuRUgE9nuR/b6P/MWHZpJMKU=; b=pePjTXNUb0/gwzB+PIeyZj7Fr5AfgwP7mNQ3hKbcGBeSt/9cx7LWuH729Hw/lvB2Kg JDrz41rKP+4LuYe/jtJ6ZSx0o99EPCq41xvpjJkBtWn8UhwoK4PjY/z6L3jES/ruLhc7 OhXHINELW1FFEbetSYD36E8/GCMTZRifVximkZUFWOmI/li7Vq43Bw8/6sKip1Zc7hH3 n3HmLBRlUCsNi7dn0FkqlfjxXwu4FP1WhmWy5mRlYo6UX+kbrXLE5xZhYtbfWsaGzao3 UZub3uhkCJ8nybdtkc65zqWjkJY63ULWwjhUi0dax2HVcK5n8BZ3ZuCmFm6sQF8sx1dV hGJQ== X-Forwarded-Encrypted: i=1; AJvYcCX25QUUZbB7F1OsXU5SW2YQY+o9/NTx0lrth43TjfMvEiEx1oyRSZrgAbBrHTdbYvngHpwqwn4z+Q==@kvack.org X-Gm-Message-State: AOJu0YznSmU0YRxZV4tZHQ/yxGTfFSDtfczfoaaLEYnA83fMfIwfuHec lePe+Cfc+Nb43b1lk/Y+FNoz/T87WtK+6tqHGt28vv2CHfgunLYk3mHG1RIUKBM= X-Gm-Gg: ASbGncu6rJVJamuZJhMBMIr1QGecbPGbkSka4j+IAbUP95GbUfEtgBGlNbwQdblWu49 Y6pH5AJKAapJkmsNMTO94MNYM6pBWpo8veaNdW8tjgrEsrjUojBbWWtjScvkxBXqOSx/1K9RacA 2iT0tBgwtgWaHPU6INSJrwZDThYeX1D/sgYf/T+B+1Y698PJnM7YDCSIHM1wKgEQsgV1vTlhnZg ccY28laV++hfUu9Vz+XWlGW4yGLegXsI1g0u99guqFgENR3AYaQ9LeVRmBP0w5V4pWZJePYb8K/ 1U9TqhILwOQ40GxzqrLo+5UjtlFoGNAUsos7ijtb1+o= X-Google-Smtp-Source: AGHT+IFSketQllVNw0jtTxWFYdUDUo0SMM0ON8BTORWBomp0X+4PY2gDNSvSpYktg5pUI0cT5GzZwQ== X-Received: by 2002:a05:622a:1b87:b0:472:6ac:24a1 with SMTP id d75a77b69052e-474bc0f6cb1mr213334211cf.37.1741038928876; Mon, 03 Mar 2025 13:55:28 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with UTF8SMTPSA id d75a77b69052e-474691a1f78sm63406451cf.14.2025.03.03.13.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Mar 2025 13:55:27 -0800 (PST) Date: Mon, 3 Mar 2025 16:55:24 -0500 From: Johannes Weiner To: Yosry Ahmed Cc: Nhat Pham , akpm@linux-foundation.org, chengming.zhou@linux.dev, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] page_io: zswap: do not crash the kernel on decompression failure Message-ID: <20250303215524.GD120597@cmpxchg.org> References: <20250303200627.2102890-1-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: DCBF810000B X-Rspamd-Server: rspam09 X-Stat-Signature: gwz1giwbo1sqjtr3hkqs1e934wiagkaz X-HE-Tag: 1741038929-648325 X-HE-Meta: U2FsdGVkX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alX+uZvMvnx+NjQappu9DT5wtDb4PxfJ5Qpre5ii1NNuUsUOOXDn6g7n42nuubAGm/oXuBnckOngR85tt0dheWp7KfLo7sbO4wGuJZvXKiTGGaGsJDGHVSsEfVIRoY4qFxgp/rSAbfPOqKRz+HyrYAvUU/TBtf4gpI6uHa8K3VMAoQX5sFNj8wdiRGmKmGJCy5tPsn2PISa+MJKYbD1dvH0NQdrEmQ+BAutnjnDupGVpdAGKURI+A9XvaP22fHJ73Bc8YX02z0NZ2eyS+0WoTIIFFOXckgTqNmZ+N0vI/gASZ+XdzKV16vQCGSnm/HSL90+KUbVaB+qx0EsZAfS50SDRREl0r5yMaS36E7OsXdl2ZZ1MEMhp25ivkaF8cn8ypTH4zS+ZgWo8fwjMmLnYGeTkd+ubAaEwe X-Bogosity: Ham, tests=bogofilter, spamicity=0.005884, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Mar 03, 2025 at 09:21:27PM +0000, Yosry Ahmed wrote: > On Mon, Mar 03, 2025 at 12:06:27PM -0800, Nhat Pham wrote: > > @@ -635,13 +652,11 @@ void swap_read_folio(struct folio *folio, struct swap_iocb **plug) > > } > > delayacct_swapin_start(); > > > > - if (swap_read_folio_zeromap(folio)) { > > - folio_unlock(folio); > > + if (swap_read_folio_zeromap(folio) != -ENOENT) > > goto finish; > > I would split the zeromap change into a separate patch, but it's > probably fine either way. +1 > > @@ -1025,12 +1028,31 @@ static void zswap_decompress(struct zswap_entry *entry, struct folio *folio) > > sg_init_table(&output, 1); > > sg_set_folio(&output, folio, PAGE_SIZE, 0); > > acomp_request_set_params(acomp_ctx->req, &input, &output, entry->length, PAGE_SIZE); > > - BUG_ON(crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait)); > > - BUG_ON(acomp_ctx->req->dlen != PAGE_SIZE); > > + decomp_ret = crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait); > > + dlen = acomp_ctx->req->dlen; > > > > if (src != acomp_ctx->buffer) > > zpool_unmap_handle(zpool, entry->handle); > > acomp_ctx_put_unlock(acomp_ctx); > > + > > + if (decomp_ret || dlen != PAGE_SIZE) { > > + zswap_decompress_fail++; > > + pr_alert_ratelimited( > > + "decompression failed with returned value %d on zswap entry with " > > nit: Decompression* > > I am also wondering how this looks like in dmesg? Is the line too long > to be read? Should we add some line breaks (e.g. like > warn_sysctl_write()), we could probably also put this in a helper to > keep this function visually easy to follow. If it were more interwoven, I would agree. But it's only followed by the return true, false. Moving it out of line would need another name in the zswap namespace and also take an awkward amount of parameters, so IMO more taxing on the reader. But maybe do if (!decomp_ret && dlen == PAGE_SIZE) return true, and then save an indentation for the error part? > > + "swap entry value %08lx, swap type %d, and swap offset %lu. " > > + "compression algorithm is %s. compressed size is %u bytes, and " > > + "decompressed size is %u bytes.\n", Any objections to shortening it and avoiding the line length issue? Even with \n's, this is still a lot of characters to dump 10x/5s. And it's not like the debug info is super useful to anyone but kernel developers, who in turn wouldn't have an issue interpreting this: pr_alert_ratelimited("Decompression error from zswap (%d:%lu %s %u->%d)\n", swptype, swpoffset, name, clen, dlen); > > + decomp_ret, > > + entry->swpentry.val, > > + swp_type(entry->swpentry), > > + swp_offset(entry->swpentry), > > + entry->pool->tfm_name, > > + entry->length, > > + acomp_ctx->req->dlen);