Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1346648lqt; Wed, 20 Mar 2024 00:24:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVChU1/gIeIJcp7ZRvgzGRNtLMQW3waiZGZXa2S0T4AUgUolal7k+Uiue9XTctLnMNfGENc+8Lo7xQ4VoatsFmADlnRFveUH93mOTR7Qw== X-Google-Smtp-Source: AGHT+IGvUwEZTiG52V1OT8YN0kZL+3Cj75KSfjzFNgW2xOR/SGyMD+3a3lkhG3yYA0IRUNjjIERA X-Received: by 2002:a05:6870:4301:b0:21f:aad7:6888 with SMTP id w1-20020a056870430100b0021faad76888mr1280947oah.28.1710919485437; Wed, 20 Mar 2024 00:24:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710919485; cv=pass; d=google.com; s=arc-20160816; b=S3QIMGTJb3UfYW6AOT4DpyvZr7HD6GM8mXscFN6fEpVDPhZkeY89fcFViIyV7g1Ier gXznQgXI8HwrcgdWKy3A1G6aLNsrOD8zhMyDHRH8cFVMw0p5r4mSxy8L7OTQ1+D+I4AS SVU4D0PuMIbD894EG6JnB7Q+3pCViqkvxqXZUPcIoLsFuIAIWRB45CBgHFS+aGDTAjBq 5fnAU84IAJRuDWJt9cDYzpPgW4PAeNAH+LpxDL+aDkI3c4MVcoKYTx4+aESv5YS8FB6z B2nmVJWHIH8q7KhdIG0PVsJtyux4RGLRizCTt7dfGoZo1o5NEJ5sgfdZMhvlxLT88KSP SY1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=bdxVN0VZOTjmFNJigRO9F2rl5jmImdVJnsiuxriNi0Y=; fh=wMN3crMEWQOUQYtHBsrbdVm3020/0OFiQ//8IiO0Grw=; b=LUNrnrvi26fRTbyRPAftUdhQn/lIzVbNH3bg3Xl7HMvsU30ITrGdJnjutrd70QGpuw Lbyf7DSUDbu1wWbsF9rOnxlRhkI6gPlEHu0OVehs4d8C+Nl4iTeGCanmuIrU/j9XgSLl C1sg5LM0xa8+/ZdqLi4qDMgBG4fomhuXv83spjxC86CSjDY1Wx9DH2Skj64T3gnpBql8 zUR9bBhr+EGfdLoR2E5nUTJy3r+aZDN6uwJszrWcldk9HyqQFB0p2fq9hbIJDEgjyMY6 uKvIfieh1nJ+Z0V642z3GHvfxPFpUPVo7SZ0MXr4VJkkJsuUp9DIltpxDg/ehiU3X8O7 IYUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BoLHUiKV; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-108538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108538-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f3-20020a63de03000000b005d8bbd208desi11800402pgg.163.2024.03.20.00.24.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 00:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BoLHUiKV; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-108538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108538-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7F0A4B20F7D for ; Wed, 20 Mar 2024 07:24:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69EDB20DE5; Wed, 20 Mar 2024 07:24:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BoLHUiKV" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 37BE81EEE0 for ; Wed, 20 Mar 2024 07:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710919473; cv=none; b=uSMjj+u9SrLKsrndR46g1ppXOKxQCBn4wbdYlEQsDexn3HYvkTPPKwxLaOqMcKBKUndpE4QZNTFG/t1Lv/W3NhYwjobDdduNNfiIaNpsSU0rDZpCjlnp5woJ7+KhNT8PkVwrE3Jb8VB9glZgcIhC7uDAqsfiSMsPGXKw4xHPMr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710919473; c=relaxed/simple; bh=28P57Ke0dbK+IeJ0axzZcEs9sf1skvjRGuluIRciE+8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=h3zFg12uSL4SDW79/nbOUbPHRQIKBGMBaz1wqJ88lwf7R3uu0bUuzK33dKTI4JaeVovmcYHiWKVA5eoDOceFgZUs7QAPh7XGWu0MLam0tYaASKz+7q1JF1SNwYNdpCUTLBwWAeTClR5//K9SJsH5ZM21u3KOc9lmnbYxcmF323g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BoLHUiKV; arc=none smtp.client-ip=209.85.219.202 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=flex--yosryahmed.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcbfe1a42a4so11346240276.2 for ; Wed, 20 Mar 2024 00:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710919470; x=1711524270; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=bdxVN0VZOTjmFNJigRO9F2rl5jmImdVJnsiuxriNi0Y=; b=BoLHUiKVbI13VdVfl9qbwJ4R2ynvZBitxHrALui6NzdSWYxi/xOS65ZhdmPiVPNqIS gP4wPz70I76X2tWqyhml9QpX1y/unMC2QA2wLpcY40fn/sqBwc9WMm6PiiyMS3a+QyYG Hyw7K7CjudWbsp9ux0sYcDjTUiTlg5gf89l3rkuHSDJnoV+N+5PATMAdZls/Ksrn8F0T Ld71iIQMfIOnDD3hH5AZIn209dGEzAhoo5oTT2UTAfj3X+AQl4dgEpZG3FNUrE3Tr3l2 9VlAqqhELmvGk+sonEcOaLQjZOaXKhf9IV3U+mCWDGSlWDxlY6YJgklVZx3Gb1Xd8XSQ rnHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710919470; x=1711524270; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bdxVN0VZOTjmFNJigRO9F2rl5jmImdVJnsiuxriNi0Y=; b=bu8NwstF/xM/NZi/Pm1rjvIe4i3ndXEejsO3hy/snlehHV9UdSWdj9Iuz9ZoCDtMsY ntqu0PvdmktIYb/jAVR2wMhLj/kQOKSZZyhZys6F65dw3x++iI7BjFVZqtlrA9Qni33n T7JlZHJTP2ZxppbTXFJ98UgBllw07us8d07vySJNkFMdasQYVDBUfmrcBi8GSr5nAsjx vYZi7mxOtF3+u3QGvZJCMlWP+k035drnPJERyjckSZdDnhfh3D2oAjpCZDDCn7jg0OB9 Lrgd5XKd8Re8uqyox67v0Ea41YpuSC8LxIGnYHlHdGM3enk8ZsmQlFBwA1/+oNOuf22K B6CQ== X-Forwarded-Encrypted: i=1; AJvYcCWv0nG00MSKOtiVBPyXmVCHNKlJMUBLqTT7rHcBfEY0ZL1cbx++SFx/gyEj9i7Wfsd1mysYvzjdGQuhIJ5JF+ob8Jtv1YWC4iH/ov+R X-Gm-Message-State: AOJu0YzQHkL7DLOrV0c4Qbw6EqeHIXXp0qn7nk2pdKeTmAK8/dYQl8di cYWMwfae45oZDMCSUHlzVj/nlbhGIwD/V4+6w0eLEHAqHC1TPLd3WvdLgteyUN4SMOJADRYyN6j +u2ADuvYkDZ2cfESotg== X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:100e:b0:dc9:5ef8:2b2d with SMTP id w14-20020a056902100e00b00dc95ef82b2dmr4326404ybt.4.1710919470153; Wed, 20 Mar 2024 00:24:30 -0700 (PDT) Date: Wed, 20 Mar 2024 07:24:27 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240319-zswap-xarray-v7-1-e9a03a049e86@kernel.org> Message-ID: Subject: Re: [PATCH v7] zswap: replace RB tree with xarray From: Yosry Ahmed To: Chris Li Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nhat Pham , Johannes Weiner , "Matthew Wilcox (Oracle)" , Chengming Zhou , Barry Song Content-Type: text/plain; charset="us-ascii" [..] > > > - /* map */ > > > - spin_lock(&tree->lock); > > > /* > > > - * The folio may have been dirtied again, invalidate the > > > - * possibly stale entry before inserting the new entry. > > > + * We finish initializing the entry while it's already in xarray. > > > + * This is safe because: > > > + * > > > + * 1. Concurrent stores and invalidations are excluded by folio lock. > > > + * > > > + * 2. Writeback is excluded by the entry not being on the LRU yet. > > > + * The publishing order matters to prevent writeback from seeing > > > + * an incoherent entry. > > > > As I mentioned before, writeback is also protected by the folio lock. > > Concurrent writeback will find the folio in the swapcache and abort. The > > fact that the entry is not on the LRU yet is just additional protection, > > so I don't think the publishing order actually matters here. Right? > > Right. This comment is explaining why this publishing order does not > matter. I think we are talking about the same thing here? The comment literally says "the publishing order matters.." :) I believe Johannes meant that we should only publish the entry to the LRU once it is fully initialized, to prevent writeback from using a partially initialized entry. What I am saying is that, even if we add a partially initialized entry to the zswap LRU, writeback will skip it anyway because the folio is locked in the swapcache. So basically I think the comment should say: /* * We finish initializing the entry while it's already in the * xarray. This is safe because the folio is locked in the swap * cache, which should protect against concurrent stores, * invalidations, and writeback. */ Johannes, what do you think?