Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1343577lqp; Fri, 22 Mar 2024 11:59:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWGkpKbZs5zBMpSBBd3e4H9TW2p6JljYMBGgYk191/SqrjyMKz/K+aTp8JbslRGmV4rutfeWHRo/JJa3EmOT7cjZylh1cYmnY6mU46WPg== X-Google-Smtp-Source: AGHT+IHeAaoxGYXVQhAFDl5L238gxPRTPMMu/4UuDFd7mE5rRnITOr3HArCaYi/ol9H/DUXwerZi X-Received: by 2002:a05:6870:f14c:b0:229:baf9:957f with SMTP id l12-20020a056870f14c00b00229baf9957fmr678314oac.48.1711133975792; Fri, 22 Mar 2024 11:59:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711133975; cv=pass; d=google.com; s=arc-20160816; b=gDvUmVyJp0mh71D5+QFohIMGTdYzCTXEitFObRRELBDmQl3XMEc0Q0SLz5ry5rvlT+ dwEEUYIZrW/M21U4aMPUknXTXdcSupLbfnolzPtmrN4gtnZhdxiu2KFdRvT6E/QNqYwM IZZjxg64Bn42exrLoxGgs8Ygl5l0yZlvn/QlQ3bkH3ig/fC6mdW0LknzMlHf8lU6PDAT GMebl42nAHlvnDEpV09R/Aa0W+5nlY7Vd69TkfUyokObxeNmmNQ4DXYVtNhrZdYrUKPG kX+qlnkab2yJMNQbBdzpJUap8wSMB3RiE7ZwBnrRrBICU5iw8IB06LloPdyzIRCrKK0O Y3Ng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=kn5VB94BUw/eWqkLaBFyi/LkgXiPUXB/jc3eN2ucVQY=; fh=9B2X2B1wuUiJmXVH2943vRB/3847vEqMHXYvkZpqnSs=; b=lUCGbWVy3QkdAxaBgO6MKDt4lSX3GzF6r50gM5jaMmK33BHyMvPwKHFNII2PvuIu1d EVcYu1RuZAG4JvrFWhdoeMDwdkGlHV8BRYCuAqmPxTTkkMoQ0wpPgvjaUbdwexfZt3Kv JOeZmqYm2o1rbvUFQeaV6Q6SYZmS3/ee3Bo9N7R40ou3NnZpjHOTdRVhDui6Miqd6L1h 1eHYu2jKGU6lU9RR6ah2oWdcrj6NFbigzF6JFX7B/KbwMDoiJhlp0YddP2/XgWb8df5Z WIYmUZxxF5yhHdO1OYI49ORkL20InPVDMN79f1g85MIhqcvnaaoXl9aM3pXRSQfzut+I Lweg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=uspQTaSd; 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-111973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111973-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. [147.75.48.161]) by mx.google.com with ESMTPS id c12-20020aa7880c000000b006e6ac027157si141147pfo.103.2024.03.22.11.59.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 11:59:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=uspQTaSd; 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-111973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111973-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 0E91DB22FFC for ; Fri, 22 Mar 2024 18:58:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDA1A7641F; Fri, 22 Mar 2024 18:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uspQTaSd" Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 44CD4762F1 for ; Fri, 22 Mar 2024 18:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711133931; cv=none; b=gpepg0YlHvO7lbKq7Yt1dxxdRf8qf2Zyt3dzn3sITYKTlLI9r2md1Rtaf9Ym3U8vOnJOtVdsebVGK2frAliyyb89hViLssEIH1DMODdHw7N02wLPL9xxvPgQiSefwtDUDR7FpUcKepb8Pym7uGhtXb5wln4TPtuwoREF0SSdNYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711133931; c=relaxed/simple; bh=2zmoavQwnUkySX1On4e3iFUXEz7P4YdtMJWnbUJFcws=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZDHN1SBJw991oi1hd0c+3vWYbd92npfqQtgM5ss8PZ8HrLpmHwNNr/Wby9u+o/sXL5ep/7i3E6RqHKg+9scJ8OitGKB3mEjHbys5giNxxfPvjHfISHx3Rb7qhuizK259VYfAOJ1/+EEBE4HUBFheX5ndGk1u0isyBXbHIlHTl3A= 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=uspQTaSd; arc=none smtp.client-ip=209.85.218.41 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-ej1-f41.google.com with SMTP id a640c23a62f3a-a46cc947929so346494766b.1 for ; Fri, 22 Mar 2024 11:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711133928; x=1711738728; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=kn5VB94BUw/eWqkLaBFyi/LkgXiPUXB/jc3eN2ucVQY=; b=uspQTaSdU/vtyRgn/iz68TBqci5cr2bCVhXf9icVogBrndF3SBXfqDTAqxhsqI+ufB oCHm53PcJnm8yLgDyyz2zGEvTOzSAVZq1E7EyrzT6g6jy6XIRzH/HVZJ2vvBZ9FtkiTz jJpIh1vPfcBNMD6RxRlBLBIgHyoPP66RZWucS2XbahafXyRXGWEMaaP8tX97dCZ27CXV n8TJXR2lGr0AWUvMvtAl3qU6y99T3snWIPr0+FTlp23luipoy1U1KdGJXBdVMaosPsJs /Jd5OGKCOJ4sb2XQMTCMcW7DHWZHKM6YKx4GnXJSjpMmr6y2S1HqS07EVb7qwUeHaP+d sM2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711133928; x=1711738728; h=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=kn5VB94BUw/eWqkLaBFyi/LkgXiPUXB/jc3eN2ucVQY=; b=fxEnWMzN9L61H+QTGSnGXshHbtGcjlkhIlAyVUZXhrCFBRebfZkrQpxwpYdsdEihij mid4qrkRFEcIKwBG1OL+jHuLuM/QYPxLBFOaZxyfgwXbbhwgVwQVPsLNwpdjN1x+b5B3 i8q/Ej5f4PG+zipZk43RXBZAF5KERwCrVgmSgmtgO7+0kJgng1aJI0o0ZOhs5avID0VI pHWlk++gXjENPcjGNpFwTas03RGuo/uKL+uRFrvoGGUVbkSsuV7r2vDoRioPe9LCR+1C Xz5NmM+v6lwXmnE/6Kse9slYulGatDxwAg+3zOz4abRFiYXFZ/lIp/u4rfGowl2KsjTI Vwdg== X-Forwarded-Encrypted: i=1; AJvYcCVa23ESTfI/40Mhlwwlygb8WwbZanqUUxBUM5QNtwOsHwJpGdIWtBfCiJ0maQ3wFfgsluyA6aF/khPPDq3DlPDazkNzMdf0fatHeWkS X-Gm-Message-State: AOJu0Yzw+TuOC7vqM5sjjSGeWtimlV7cVlGBjgDm/+THnctMC9icbAd+ peC5LacXHOrSJINrTJgtPbLjZU5lTAL6hh8e1Mz8yuqxo3ZR4mVYsWhJcpioXC0i24G05xsUHaA oNgH/Tr4+2MQSbEcm3XomYJaUNZs9Ken6syjCeY8Fqqmi4xckPQ== X-Received: by 2002:a17:906:f2d9:b0:a46:fd41:4bb8 with SMTP id gz25-20020a170906f2d900b00a46fd414bb8mr415771ejb.25.1711133928342; Fri, 22 Mar 2024 11:58:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240321-zswap-fill-v1-1-b6180dbf7c27@kernel.org> <20240322031907.GA237176@cmpxchg.org> <20240322171156.GC237176@cmpxchg.org> In-Reply-To: <20240322171156.GC237176@cmpxchg.org> From: Yosry Ahmed Date: Fri, 22 Mar 2024 11:58:12 -0700 Message-ID: Subject: Re: [PATCH] zswap: initialize entry->pool on same filled entry To: Johannes Weiner Cc: Chris Li , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nhat Pham , Chengming Zhou Content-Type: text/plain; charset="UTF-8" [..] > > > What would actually be safer is to make the two subtypes explicit, and > > > not have unused/ambiguous/overloaded members at all: > > > > > > struct zswap_entry { > > > unsigned int length; > > > struct obj_cgroup *objcg; > > > }; > > > > > > struct zswap_compressed_entry { > > > struct zswap_entry entry; > > > struct zswap_pool *pool; > > > unsigned long handle; > > > struct list_head lru; > > > swp_entry_t swpentry; > > > }; > > > > > > struct zswap_samefilled_entry { > > > struct zswap_entry entry; > > > unsigned long value; > > > }; > > > > I think the 3 struct with embedded and container of is a bit complex, > > because the state breaks into different struct members > > That's kind of the point. They're different types that have their own > rules and code paths. The code as it is right now makes it seem like > they're almost the same. From the above you can see that they have > actually almost nothing in common (the bits in struct zswap_entry). > > This would force the code to show the difference as well. > > Depending on how Yosry's patches work out, this may or may not be > worth doing. It's just an idea that could help make it easier. I initially wanted to do something similar to splitting the structs before not allocating an entry at all for same-filled pages, but I ended up dropping it as the direct conversion was simple enough. Anyway, I will post the patches some time next week (or today if I can get around to test them). The discussion should be easier with code.