Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1379715lqt; Fri, 7 Jun 2024 17:33:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9/m9f+T7WYAKDICKvdVIoX3WPYOfqlCslvT4rN/6kAFDEIhq9Qpri4K1kmCG26PyT1Xqcks+l2EPDrPSxvA87jVQBhcQVTExFdfWWWw== X-Google-Smtp-Source: AGHT+IGbmM1DpenSD6AMpd+B2xVUOmrS6OrQ/8Pm6kysKwm6mbDhwq0+wRALGi/v2Vcr4d+ji56S X-Received: by 2002:a17:902:ce08:b0:1f6:719f:246e with SMTP id d9443c01a7336-1f6d03e5d30mr54362155ad.67.1717806781609; Fri, 07 Jun 2024 17:33:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717806781; cv=pass; d=google.com; s=arc-20160816; b=TAFOTUHJCm3BC7dqHMNCp+6k4tr9oeEd0r7jCSYAqMd2cuLSP6oIyfsWktOKR4LQkh QnIH0pu1LVC7rpAM4IEqs5ybOrtesRvj+pZanJzZfoyOEdo78TYfsqDxfMlbOFTVgNTb NJDhVgvM3tmHZpuY7xfIYH3DwznIVHsq8WOtOH7fXj5vRPjpbxwgCCgx3b7bd2RQFAvV Z6GpxhPAyavq8j97/QdrJv/JwNUyZFDbdybJEkzIAu3CJoMTpWfLQhD7Ps+B4eICI/8E fFvR7nvWYGKpv2Vne2nssbYLpa27qz2rpftTskgoTm+xoP9J+QyhY3qekN/K0U/q6gC/ 0pOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Gjga0hn0EKlhttYQ3pJWY9jgRupfj6fc9njlrirZU18=; fh=xmiT8GYbl4sKOjOwr7nHqXjf5HTAMPEp6PmLuoGezcw=; b=qpVUThzsqBxRwaj9CZ1MilHk3C/gyh5SgFzOVnk+Vq9Jziy4B8vKRmgR3nYuyG83u/ swovwMProCMlpBr8rxEikPE8NujQnENNJsY0RFT6S+Xr9YzxqajwbyRkVDcL05ZT4Qsk rOAfQ6B0pKkHJda5R45Ta0h+fuI6DBf5HEmY9QLo94YGSNC80C4iZrQ2mh4L7Kq3aDsM iqNLC0qrGjdtHrBRDHcMIkTWPhQo3I9xr+K05U26ftX3/Yg0FkIcA4iiXvYTFkZgqQxe FApqpU1BSxYXQUKJsI7bKMt5PdH7XTNEzvogroJ+LKdATWwKwdOUggFBoLsf0P6z3EpQ fYbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WgjUOQpV; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-206857-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd75fba9si38944825ad.47.2024.06.07.17.33.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 17:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206857-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WgjUOQpV; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-206857-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1A268282AD6 for ; Sat, 8 Jun 2024 00:33:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 930B733FD; Sat, 8 Jun 2024 00:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WgjUOQpV" Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 238EA1391 for ; Sat, 8 Jun 2024 00:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717806773; cv=none; b=haUO2IImx6j9ppCMDX4K4/CWiTA5acfnOC+Bdh58RNr7bAS9mwmP5GRLjfV0zai1qr91W4zd1sK68o0Rx55PSqS2/mNK6hQ4v//shqeIo+y/EzlSYyTTZMfqQY/pkFchpcNmzhLnqt/n/9kZ2G51nljTw5Mtn6ccX+hAA81PkSY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717806773; c=relaxed/simple; bh=Gjga0hn0EKlhttYQ3pJWY9jgRupfj6fc9njlrirZU18=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=K2LTx70+qbEzrsYTAg9XpfPFwUh8NtYYjVecFd+GM7tAvO9DhN6QJNDc1CZl//oown/Ou0e2hAmntGLzZkPPW0TgPOK/U4JSTbo6sPjn9yBfsSVoJj5/eZuUWHvE2c2weuIwNBYJkmTF54Io0Q3HPmTxABNIeYdsA3HLnHXTcPc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=WgjUOQpV; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-579fa270e53so4059121a12.3 for ; Fri, 07 Jun 2024 17:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717806770; x=1718411570; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Gjga0hn0EKlhttYQ3pJWY9jgRupfj6fc9njlrirZU18=; b=WgjUOQpVszBXyV5B3we64OkkpL+xfrorIdIrsGr5hZDR5obU806t1jPd7NYjach4NB gDkzYNXyNwYVr55gYZubtWHeEm2AB/IW2Efah+0dWK/fjpdCWWM8udcxH7B9tyJalqDs 6mpI/OwXEfMktl2lUFWAb56dIAm5TGcfBYkhOgK94FqXmyB5jJeYKxZjW9dFrD3fAncx YTkGGhBSHZJEUbT6Wpu1ubxJo2gQ7YEHv9ouWxiCqCurbKY8glUgc6X4HJKcG28cZItx dAVC72hb+Pxir8y7k1xbOlg+sJ7GpHqZKSwVTSks5ZFc7Zzw+WW5iMIrfUxPgI2tomjr dH0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717806770; x=1718411570; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gjga0hn0EKlhttYQ3pJWY9jgRupfj6fc9njlrirZU18=; b=Cl5SFpk3NHAOOXHNAi/nJd+vJGsOuKFudgayZuy+w6rYE5hnl5jMgY5r0idO42mnuh siOR6xnXkC46vc2+9V11RGXLX9YTLKcchrQm8ZcI3DRUD67GQynqGnvo5lDb4O+q6Y8X 8Iv1Q2Dm7OIA5ri13QtPy0zjV82jZYQqe2iSQOS8IZQx+by1oKpUZfqCEtLHdpo5nuMh 9WYr3TmE7flnsE469ncTge+lPMAOLtls8gk5jhtuFDrdTzlA1xt/5Kqu3H6j0mrWA9Or t1+Hi0EBR+e/lbnAmkQBhcHmIB3oDA8S8gRl93RVN79iLTx2VuGhkuR7YvLFexBtGdrg c6lg== X-Forwarded-Encrypted: i=1; AJvYcCU+6a7XC516mwITd5wouAOxAZqAbrRMGGUBAymXRQqUWmzrN5kzz5Lr7nCyqxkq5+S7+gk/WAlemKFmC++e2onCmeNV0szsboYBqjiU X-Gm-Message-State: AOJu0Yyg54USTp9+42e9UpThWJF5SYhyYKw5KOttscDVzI6EqHn7ImcB kEfcwSKYqCTbqF0vZKmx3eiF91Bm4oPjtAvfzoHO13QOx6wOU7If2adBYHc3IUJiDh4BdiuSf/I +3ETZE9WGS8Z9YsQfRzwMAmQRyxiKClPEdpGw X-Received: by 2002:a17:906:3299:b0:a62:cf3b:77ad with SMTP id a640c23a62f3a-a6cdaa07abfmr290069566b.49.1717806770173; Fri, 07 Jun 2024 17:32:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240606184818.1566920-1-yosryahmed@google.com> <84d78362-e75c-40c8-b6c2-56d5d5292aa7@redhat.com> <7507d075-9f4d-4a9b-836c-1fbb2fbd2257@redhat.com> <9374758d-9f81-4e4f-8405-1f972234173e@redhat.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 7 Jun 2024 17:32:13 -0700 Message-ID: Subject: Re: [PATCH] mm: zswap: add VM_BUG_ON() if large folio swapin is attempted To: Barry Song <21cnbao@gmail.com> Cc: David Hildenbrand , Andrew Morton , Johannes Weiner , Nhat Pham , Chengming Zhou , Baolin Wang , Chris Li , Ryan Roberts , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jun 7, 2024 at 4:28=E2=80=AFPM Barry Song <21cnbao@gmail.com> wrote= : > > On Sat, Jun 8, 2024 at 7:17=E2=80=AFAM Yosry Ahmed wrote: > > > > [..] > > > > One problem is that even if zswap was never enabled, the warning wi= ll > > > > be emitted just if CONFIG_ZSWAP is on. Perhaps we need a variable o= r > > > > static key if zswap was "ever" enabled. > > > > > > > > Barry, I suspect your is_zswap_enabled() check is deficient for > > > > similar reasons, zswap could have been enabled before then became > > > > disabled. > > > > > > I don't understand this. if zswap was enabled before but is disabled = when > > > I am loading data, will I get corrupted data before zswap was once en= abled? > > > If not, it seems nothing important. > > > > If zswap was enabled and then disabled, some pages may still be in > > zswap. We do not load the pages from zswap when it is disabled, we > > just stop storing new pages. > > > > So if you just rely in checking whether zswap is enabled at swapin > > time to decide whether to use large folios, you may end up with a > > situation where zswap is disabled, yet parts of the large folio you > > are trying to swapin (or all of it) is in zswap. > > > > This is why I think we'll need to track whether zswap was ever enabled > > instead (or if a page was ever stored). > > Thanks! It doesn't seem good. Do we have a simple way to clean zswap > when it is disabled? seems not easy? Just like we do swapoff, or disable > cache, we ensure they are clean - this is a real "disable". I think it's just simpler, and disabling zswap at runtime is not that common. Keep in mind that if zswap being disabled takes time, then we'll want to handle races between zswap being disabled and incoming swapins, it will probably end up being a state machine or so. Without a valid use case, I think the complexity is not justified. It's probably simpler to just track if zswap was ever used, and disable large folio swapin. This should be a transitional state anyway.