Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp893104lqs; Fri, 14 Jun 2024 08:33:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWQrFsSL6KLzXgkmLUr8jkqM6y9W89Edcn5FtgU0g5eEju9ji+tx0pFPp0chZonQsxGUbr/lUAOICijxt++rhehDz8wUo/YXE3cMWXFw== X-Google-Smtp-Source: AGHT+IHvwXI/ceZXelHnT9q8fLSDJrcHnBlX0KEjfU4qiMZ2HhlDP+ZHJrHvLazAwFm4Z+hlSnBb X-Received: by 2002:a05:6a20:f393:b0:1b8:5ac6:4bd8 with SMTP id adf61e73a8af0-1bae7e89431mr3170627637.28.1718379179788; Fri, 14 Jun 2024 08:32:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718379179; cv=pass; d=google.com; s=arc-20160816; b=F4uBiMg6w3m5YRGruIoYaeGGjUV6xJc7150+5z/BmdWU7di0uqOwmY16yrRk1WeZ/Y AphvrIseJClSzTqkggyl+KtLU9iIrsJku07yIeOd4zAx1UTN1pmAiYjBjX2F/r4l4elI uiXGHk5/fN0xDaAJv4MetsllsCl4B7yCAQeiAc4rPuMmGS3GIADMCOuTbf1WiX/T26/V 9rZKZdngs68i9BzYMgcczfN/l1i7Ynn8JB2442mBJ3AqVULIr4M/X/lE3kU8GLkIXU+R YhF2eXKx8Rw8s8/6PLXNMLHQTrguA3mLe23R+ISJpGNa3QbETAsjo6Wo+Ob2VZWxGZMz Ovgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Z+iLuqVadCoqCg4bKDGvoLPKxtcgCGNFeClX6r1NiCA=; fh=wyakK4+SyLjyn8wkJqujp4M3Zfjg2yaS63lo8MtwL3A=; b=CKa/mdyjpe5MgyjM0/vSyIQVsifWTD+Ry9sFnArU/cW4LtnrURWH9vwijxC0MJ5aL1 MIFncEIAa2rxY45nHFHzu2OKrwioiAnGQlkcSssTTUVy1KfgRYb1trfFcXm5zYsKBZIO 6bMread0Nk+kpRHwfRf5msGoeIB4SlvnePdcKXVPS+4cSyedcUWnh1qdvUUEnSneZr1C z7owDYdHHpU7Qz1TE5Xnu5+iylKO+uAZ1TIwT14LoDU/ZgeDse/ET53Oc/EHwwJM+1QP /oi70Ic96YsELd3NKLIwTXRSLdpU5PBm7N7XKbjTxyy+xu7IN7wpZE2GC7L2zUu3i5sG TyTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="j9UXk4/j"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-215095-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee453b9d8si3741083a12.463.2024.06.14.08.32.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:32:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215095-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=@gmail.com header.s=20230601 header.b="j9UXk4/j"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-215095-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 A05BAB24059 for ; Fri, 14 Jun 2024 15:07:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AB791AC255; Fri, 14 Jun 2024 15:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j9UXk4/j" Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 1CC531AC248 for ; Fri, 14 Jun 2024 15:02:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377361; cv=none; b=AiraayDldHFEV3YBZtN0aDYvAVT36vqWodg5Cv6EmRtTWh4mzcp/xgnb+UIZCG5omZl0WiZLdgAzDR+TsV7Xbgi4nEIz1L9dFJy9CyP49MsVkwm1KYlyAqNNYgMGldhS/QgZ2XWH0P2uF4cJmO6ckQZnCf59WgDOYewXEzsH/EI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377361; c=relaxed/simple; bh=cLLeoh++naBGPQZLkDFcvWY+Rf/9V91jd3U2YZI8/HA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IA7od/jVFX+JAzAPFuI5UXsy56ieJ834tfEpA4MjGB26LKeY0+SqSJ2VARtMHzZcTQauzR3L1yPyecrgMdeh1h9iCKUjSbPo6tlVCfRzn4ni+90hFiw9kzNgtqoJv3kCgYg9B3Ezn0S6ptSA+VfNXmcY0Xf4Z7I50AbaHKX2Als= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j9UXk4/j; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-35f1c209893so2560279f8f.2 for ; Fri, 14 Jun 2024 08:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718377358; x=1718982158; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Z+iLuqVadCoqCg4bKDGvoLPKxtcgCGNFeClX6r1NiCA=; b=j9UXk4/jQBoaky4Q4W8MJHiBosrGanyfdvGgf4s/ebVn71PIGOA0QbkyUhoiLzhbv1 viY78OgMszsmFESq2fVT06M9AKAyfYyvI/bVczfVn68aTmrR1EA2+9C/IEt0lW1UVOBC 7u4G0wOqaN1w6f1p8brKrkMSzFcP1ko7z0uQPTP/v5VU6nKdnA/g19k1GMUgJkHQVp1d p0JN5DhYJ8NokQ+g29HntqNDgcDpCF5X+g78Us5RIWrQKWFfvHgw8TXd18nfW9Ir5tNa iQxmyLMxsOqUNf/GFVCyzCkthqAzh+gXMcK5MxVpD2zEPNSnjiyTASWXrdgTeGUehhyF GCOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718377358; x=1718982158; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Z+iLuqVadCoqCg4bKDGvoLPKxtcgCGNFeClX6r1NiCA=; b=opKGd71/OvFx+eRJsIqFRz2QHqq5oyOD4EqP6Qnizjkxub8ZaXdLq/RAerXZ80K8qB cHIkdo87H5iAsQMTwpbed1fiUnlNnUNbS6t3tUrpGLZNhXowRezlM2VMXy8yFyUTxUbc Acu9fJsJ1p25IxgJ8seakigk+DSINy53kb5Ug5WwRvWG7z+dshoKnuU7q27CIOxCOr0U khO83ImtenJF5YxmTKEMos+VoI6OMgRT7/uwQaXqXMtIFR8eKze1zbXCSLaeylxhU0+A rxMeia42sFUYzBLKOhGJPCMooMnkHMvzoAVSzNYc9WuimiH1OmQOEdPE5tY7BsHJLS/7 sLkQ== X-Forwarded-Encrypted: i=1; AJvYcCW3v7BhqT4HN7Aryf4xHNpo/ym+V3mSiVvFYZCQC3WS55QMzQr+hJuakwnmy9kaD4td2iHscM/5FhyKk/bFoSW2wv6yLRBfJUbcrHMK X-Gm-Message-State: AOJu0YwzVy/7Jb5KoSgh0q0vct1U+4SP0kxGUuEmHL4+6TBc20bG0rHE bx6vDuS3abkoGtyTAdsNsfifOVbD0u+SAqicf/CxCheG6IZdSIeR X-Received: by 2002:a5d:6650:0:b0:360:8636:7791 with SMTP id ffacd0b85a97d-36086367874mr1132004f8f.16.1718377358198; Fri, 14 Jun 2024 08:02:38 -0700 (PDT) Received: from ?IPV6:2a02:6b6a:b75d:0:64:3301:4710:ec21? ([2a02:6b6a:b75d:0:64:3301:4710:ec21]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750f2489sm4630081f8f.69.2024.06.14.08.02.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jun 2024 08:02:37 -0700 (PDT) Message-ID: Date: Fri, 14 Jun 2024 16:02:37 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/2] mm: store zero pages to be swapped out in a bitmap To: Andi Kleen Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, shakeel.butt@linux.dev, david@redhat.com, ying.huang@intel.com, hughd@google.com, willy@infradead.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com References: <20240614100902.3469724-1-usamaarif642@gmail.com> <20240614100902.3469724-2-usamaarif642@gmail.com> <87ed8zmvla.fsf@linux.intel.com> Content-Language: en-US From: Usama Arif In-Reply-To: <87ed8zmvla.fsf@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 14/06/2024 15:45, Andi Kleen wrote: > Usama Arif writes: > >> Approximately 10-20% of pages to be swapped out are zero pages [1]. >> Rather than reading/writing these pages to flash resulting >> in increased I/O and flash wear, a bitmap can be used to mark these >> pages as zero at write time, and the pages can be filled at >> read time if the bit corresponding to the page is set. >> With this patch, NVMe writes in Meta server fleet decreased >> by almost 10% with conventional swap setup (zswap disabled). >> >> [1] https://lore.kernel.org/all/20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0@epcms5p1/ > But how much did the CPU time increase? Surely the new loop is not free? > > -Andi It is negligible. For a zero filled page, without zero-fill optimization, the CPU would have to do page compression in zswap or dispatch write to disk, so this optimization is just replacing the CPU usage for these tasks with CPU usage for checking if page is zero-filled. This is the reason why same-filled optimization was there in zswap. Zswap should focus on actual compression and this series is just moving the optimization to swap. For a non-zero filled page, the loop quits the first instance you see non zero data and checks the last word first, so its likely going to quite very early on in the loop.