Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp29821lqh; Thu, 30 May 2024 12:58:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNie62imRl4wJW1CBfJhZPiTMSS8H91FbRd5AofG0dzu/Mtucdtr4784SIzI34MHJbPkSfi8TK1JGNb6KPLU/w4zjngmN3Y992VUyaNQ== X-Google-Smtp-Source: AGHT+IGQ8WfUnpT7v6wEjh5Mody6OaDk/msfLxut4X6RVJVInLyKSFV6bLvqVEODBvfBfII9jQHz X-Received: by 2002:a17:906:a84:b0:a5a:51dc:d12 with SMTP id a640c23a62f3a-a65e8d36441mr305076566b.2.1717099121660; Thu, 30 May 2024 12:58:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717099121; cv=pass; d=google.com; s=arc-20160816; b=m5+kKRxWrZxl4i/4GKYBo+ptEbSoQingRwr6cixbmpbSj8IlbcXhUQokspeNsdvm+N DlEiWgarHadwP0kygLF0L78ksdLyQRVvNXjNtpwpkPT+gerzgQD28hORXr5UqCWCq3z9 4DRkipLMKl4CknKPAwHCFCm1fkRe1I95n6TtqK//szjv/fwQeaaphkuP3AscqsdgmDg7 Swtw04oejoCAWNJtuvdl+rK0aFLbpfXYBhzrPLiVrP6MnhfLeXOhKdpIWPbha4j10Lpj 0lh6GgIaz5uIPS38UPTRNL1SokVe2kb+4oQ0u7KI1rALC5r3beH/lxTfA6Ue7sd31GsU lBSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=wzuDzdXkt24X860GqJ2/APbT7XtVHPPAjBED6p+6MjY=; fh=YtiNUISpfTF9Ux4+BRlDGhaLWgcFXAlh9TrD8JxNY/g=; b=XZjmb8OdaOxV9Uv8SiziJMigBQtyeWJvzHSVTP6RiaEWxVnAAw4jcJL35dbRF7Mt6e G31ke6RkbE4/MR5ylbTAvlJgQBdwHfltcGbdzfSx1cFrJlIVW7wzkw0tmQ3V3ZdiA9CG Ez2l7Kz+yCnYt+zBoGGCCwSkWPzePhsNJTzcUZ8afE3UwwvsqD7BtraUC/QkcdwK5xF3 mkJFfss910k05dCJnWDjFtDtJqHHE0lUlrV2T6sAhfng5sAKTG4ez0aBDc+TwfYFKbNG b+XM8FMcof6o/1LMl14FWaptJb4V4qb3yijBE/ylEi85nexe3asmRdbL8TZd/Nz03A18 GLPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="If/Yt85F"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-195845-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195845-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a67ea38e3f4si9295966b.415.2024.05.30.12.58.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 12:58:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195845-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="If/Yt85F"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-195845-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195845-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5F6EA1F2166A for ; Thu, 30 May 2024 19:58:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1830F142E6F; Thu, 30 May 2024 19:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="If/Yt85F" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9D11433CA for ; Thu, 30 May 2024 19:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717099115; cv=none; b=fTP0kCTkVO245jUv/sw7lGM9rMFrsSuEtUKvG3m/jUTm5YFIq/K4ETW9vICnxlUmruYpqVmN8TeiMoDEb1kfpG6UobtLn+myhzBOfOr3xZMQln6CaID4t8PW/NRA/nuG8AIHiFoqpvxEyVHlDSXcrN95CG+/QS6QJWPdnytj73E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717099115; c=relaxed/simple; bh=QQhN3fBeDsJ4TwxAMRYmU9fsJQ0uQBGkrfT06jVyz5o=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=X0Dbhf150xsQ9jwgEI5TPCXE9Doh0hg8fg/CG2f5YI/tocw1zF6PWLptyRdhAeDxEmpmQoWKu8oMoVQ8FK/zWdjAdkuNuZHnA94pikm9HmZvRT9ROSIlYCEqeqyqoqllctlyvkqXf12iUI/ojdZV7NDhK1aN3mi401GBMKUWO6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=If/Yt85F; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A9ECC2BBFC; Thu, 30 May 2024 19:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1717099114; bh=QQhN3fBeDsJ4TwxAMRYmU9fsJQ0uQBGkrfT06jVyz5o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=If/Yt85FbL+jFdwt1w/gf/EevPCse9Y3igXw2uHHogWsSGRxEKO4vXk9UF5qKAsin CM27YDG+5zkC3k9/bXmaXHmwma0bmMZLZEVlcVrPLt37lPjIAAXZKbjarwyxzTooXI UVmZahKLlVewfvFCfLjNuH+RSmgffQ7Hd9CtXElM= Date: Thu, 30 May 2024 12:58:33 -0700 From: Andrew Morton To: Usama Arif Cc: hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 1/2] mm: store zero pages to be swapped out in a bitmap Message-Id: <20240530125833.fd5315f80316436e93f91dfb@linux-foundation.org> In-Reply-To: <20240530102126.357438-2-usamaarif642@gmail.com> References: <20240530102126.357438-1-usamaarif642@gmail.com> <20240530102126.357438-2-usamaarif642@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 30 May 2024 11:19:07 +0100 Usama Arif wrote: > 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). A little nitlet as you'll be altering the code... > --- a/mm/page_io.c > +++ b/mm/page_io.c > @@ -172,6 +172,77 @@ int generic_swapfile_activate(struct swap_info_struct *sis, > goto out; > } > > +static bool is_folio_page_zero_filled(struct folio *folio, int i) > +{ > + unsigned long *page; > + unsigned int pos; > + bool ret = false; > + > + page = kmap_local_folio(folio, i * PAGE_SIZE); It's rather expected that a local variable called `page' has type `struct page *'. Can we use something like `addr' here? > + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { > + if (page[pos] != 0) > + goto out; > + } > + ret = true; > +out: > + kunmap_local(page); > + return ret; > +}