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 349C3C43334 for ; Tue, 21 Jun 2022 09:08:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B49768E0001; Tue, 21 Jun 2022 05:08:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF8C46B0073; Tue, 21 Jun 2022 05:08:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C06E8E0001; Tue, 21 Jun 2022 05:08:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8CE116B0072 for ; Tue, 21 Jun 2022 05:08:10 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5DC17E8D for ; Tue, 21 Jun 2022 09:08:10 +0000 (UTC) X-FDA: 79601666340.28.69BB67F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id EDB8110000D for ; Tue, 21 Jun 2022 09:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655802489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HrvFAtHiRGXQ/g4Rkyn4BFDkTJc7ZTUm0jCP8JjX7pE=; b=YSc5Vb4H17qiLzVR2yl/r0csXBW7SROkPwFyeCoGkXXh6/JGjXfymglxqX4abdtwOxAZ6J 7TkNGIt8qz55vPj/RaNnp9KrFrt6jJDRI8QLVgL4nOtlouzEK/O7VmeytkliiePEE1PU1T xHRKq2QoS2IMuVeDI2G/qLYRmFy3SQA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-_i0_v9AtNTesNv3kUMRETw-1; Tue, 21 Jun 2022 05:08:08 -0400 X-MC-Unique: _i0_v9AtNTesNv3kUMRETw-1 Received: by mail-wr1-f70.google.com with SMTP id u9-20020adfa189000000b0021b8b3c8f74so1712715wru.12 for ; Tue, 21 Jun 2022 02:08:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=HrvFAtHiRGXQ/g4Rkyn4BFDkTJc7ZTUm0jCP8JjX7pE=; b=6pvqGAI2eVnjozVQulvHX5xOZwIqKf+fGh8RaKQYaL24xWApB15v2wbPLVxl6T4Y/i L52R8IO9TAcCLH1ZS/zq/Q22tal0z/kud99NLvu62k5J/i5IhtoxpqptBx3Rohngx7a5 PlYR4RCVVvCryDuAcsDZS3N1t4CVZY5pYBysnG67ysPn/+lkhQsZHV+yUF23xh6QdkBJ N3nEKiFRTTdgxB5lqyTILtDZt04X3WWaUoNLrYdMCHjsQmuMB5tcY6ezsJpAG5oXouRT iJuHiX9Ixh4MkGLnLeU41jI/qk0T25aQgFlxAGxCECJEcACMjlBKaWA0rooOquLB8AUt DhAQ== X-Gm-Message-State: AOAM532HLrUnTxSfj8df+l60PU1VGJ2pElIZGJoaVIXTM70lmWGNptDC ogPLqTuN3E+BdxujjCmSAQ/PgJU0K4kXbLPPolgTbFM5W5zo7NJq/vpftBbG0nCRGpsrMbNq0pY X3MCoNmBYMU8= X-Received: by 2002:a05:600c:35d2:b0:39c:8490:abbf with SMTP id r18-20020a05600c35d200b0039c8490abbfmr39071803wmq.86.1655802487064; Tue, 21 Jun 2022 02:08:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0O6uLBdxkqgVg+gyH+b7UlyO15Ns0ARJIS3LcEgzJjUzndljXpRSNr+xifoFCsxKFAFxrPQ== X-Received: by 2002:a05:600c:35d2:b0:39c:8490:abbf with SMTP id r18-20020a05600c35d200b0039c8490abbfmr39071785wmq.86.1655802486819; Tue, 21 Jun 2022 02:08:06 -0700 (PDT) Received: from ?IPV6:2003:d8:2f04:2500:cdb0:9b78:d423:43f? (p200300d82f042500cdb09b78d423043f.dip0.t-ipconnect.de. [2003:d8:2f04:2500:cdb0:9b78:d423:43f]) by smtp.gmail.com with ESMTPSA id d5-20020a5d4f85000000b0021b862ad439sm11770889wru.9.2022.06.21.02.08.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jun 2022 02:08:06 -0700 (PDT) Message-ID: <7b6f42ea-ba97-2f73-ca7f-9ea23fa8da06@redhat.com> Date: Tue, 21 Jun 2022 11:08:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 To: Yeongjin Kwon , linux-mm@kvack.org References: From: David Hildenbrand Organization: Red Hat Subject: Re: Make zswap same filled pages copy on write In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655802490; a=rsa-sha256; cv=none; b=3q/xf6gaRRVt65zE82V3L6rUgdXzzYq4IfHtLSRCPu06ztze4QHiIiVqABnHVzCwrriZeh RwC6vOM4wEeu8w3vvDlrd3cl1SYWJRQ/r6ljzAdhkJo+RnMBfZyR6sZEQBw7SA8nLDYc/v wWTCmuYd+wlu9tEitqpa4xr8LO8VPZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655802490; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HrvFAtHiRGXQ/g4Rkyn4BFDkTJc7ZTUm0jCP8JjX7pE=; b=lxc5An42sQG8Is6LtrQtKJhzKZsfka9AN0rnW4xYR1xHi5vvXPpLE1oQoU3jlTfSM4lj+a ptff4aBK+QQsYwDeT0HmIVh68AVkK0BmP8WlGYlzqHpp9hcMSarnyy4vhHlQ2kAnvKzZ65 MNzEs2cwCkaPqaxmlui6khParq8l82M= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YSc5Vb4H; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf05.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YSc5Vb4H; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf05.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: EDB8110000D X-Stat-Signature: 3jzjq1mjxrcg9ua4nkwj65oziffep47j X-HE-Tag: 1655802489-370602 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 16.06.22 18:40, Yeongjin Kwon wrote: > Hi, > Hi > As I understand it, zswap currently handles same filled pages by > storing them uncompressed and then copying them out when they are What I get from the doc is: " Some of the pages in zswap are same-value filled pages (i.e. contents of the page have same value or repetitive pattern). These pages include zero-filled pages and they are handled differently. During store operation, a page is checked if it is a same-value filled page before compressing it. If true, the compressed length of the page is set to zero and the pattern or same-filled value is stored. " And staring at the code (zswap_is_page_same_filled()) all it does is checking for a repetitive pattern sizeof(unsigned long) pattern and storing that pattern instead of compressing. Which is an optimization for compression, not deduplication of pages. If a page is filled with 0xFF, just store "page is filled with 0xFF" instead of a pointer to a compressed chunk stating the same. > loaded. A possible alternative could be to have same filled pages that > get swapped out mapped to the page stored in zswap as copy on write in > the page table, instead of being marked as swapped out. Then reads zswap really feels like the wrong place to do something like that. Its job is not memory deduplication, it's compression. We do have KSM for deduplication. > from the "swapped out" page will just read the underlying page stored > in zswap, and the stored page will only be truly loaded/copied out > when it is written to. This is similar in concept to the copy on write > mechanism the kernel has for forking processes. Would this be worth > implementing? I am largely unfamiliar with kernel development. This is Please take a look at KSM. And maybe how KSM and similar memory deduplication techniques provide a steady stream of work for security researchers. :) -- Thanks, David / dhildenb