Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp62478lqb; Tue, 4 Jun 2024 05:18:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXX6r7i0ApnpURTybmJXoVc3BvEr/IcteurJ4yU3MMNOti/8HYDHHM9dTiS66yoHwmpl7FCTykdn/ksW9buOLwJuGVDwjoU5NQAOGLVig== X-Google-Smtp-Source: AGHT+IFTxE1EcLR1JFdsFLmOZZPZRBVGg3xFmp6vrTN6AG8CeKfUJbFwgQn3BdKaeqGhBHyzA+xo X-Received: by 2002:a17:906:370c:b0:a68:f77f:41e6 with SMTP id a640c23a62f3a-a68f77f4587mr444689966b.73.1717503517754; Tue, 04 Jun 2024 05:18:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717503517; cv=pass; d=google.com; s=arc-20160816; b=RipxtaTwOt0G3uVlScxx2a8FQeWfureTCww1CI6IAeq71RTdqfOHzfJJkzS3UO3LaW IIaHUhJId3MDkxPPpawrOfjnZUypWWhQQeXLhz+Pl/ySBJLwOEKNx53ApQmxvJKNp1ET 3gdvV1jJ2eYthp0wBwzczDdnyqfRouVj6JgrTHRkjvbKDFw1tV7WVnZDb+vIu7VN1fKM fjvdeaHh72rFEQ5qDxPdDl1nqoBFcuyDR+WyWGCVdFiz6ZucYEPJJ9l1yxatWlV27s+N HDOsCwkqD2JeqhWfcBJePoCmIMc7K3xkx2vuCGYakVe0JmPJyx+OSC6yDXWVHubbtV3K mJDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WsZvmPHfN7fPNZg3H2FzpVxdFXo8damEw8Ch/6pQZpc=; fh=2iLlvPnLNj80a3WAPcuhkGdUf8h9ZpGi33PTTg3m0+8=; b=b3NJFztKmKvSgqFdwuIP5JZwY37CqXpS9Fk7m8TL9omUxjKt4o/AOj52KblAbvbFJu xd00HaF+HGk4DY77Jxmt0QwJvB697ygYa4lvXifaroO+3voRKT4BJIp8XxlfHw44pXbQ hRc4yZFi7vcAip+G3LFvkCNgdEqCEGLqUyq2mmP2ebSFCt9EkApD5Z2qlGvciyGANIqy g/mA3Ry/16XhxDS9EgyvkgBRBNRtLh/7qEWfGV+8uGb7sqyUX24MN0ZMS50LPDlfGFS1 X2FSmZdhHhyXSKDoGO+mjrb189a0PuOZGUzvcvYpP40HSdbf/xfGPWJOPNv+My5R+7aE PIdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=D8JcCSx2; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-200574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200574-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a68e007622fsi304053966b.64.2024.06.04.05.18.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 05:18:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=D8JcCSx2; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-200574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200574-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 6F4C31F21975 for ; Tue, 4 Jun 2024 12:18:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82280145FE0; Tue, 4 Jun 2024 12:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="D8JcCSx2" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 5C74A15E8B for ; Tue, 4 Jun 2024 12:18:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717503509; cv=none; b=I0QSyf4IlqGaoJnEcamk8oeGY0Jo3qESCcEv6ASdtL4i9dSEVjH7LyPEb2WBNnt0hN3C6gGms5pl50eXw87tObKH+U1Yjq6xhhPM6ENa0vu4aZ1umiIIfndo/J6TL6U7evtgZBMqJoISlhPCM9Pxi+1DGULelZUHKm7E7Of36SY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717503509; c=relaxed/simple; bh=koi+eA2OVKj7kcTmnp29vrfYEoN22Tgf5em0FAJliKs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dSADgpN1nrK3QsVV5LI9hSR7a7VIhS+hiVXthNzUEuHwWMRq399vlvqEwtjDKomHTSVaxy/0X9DHqgfXsHNhNcn0653IkyaeNGGLBxug3oDI63GD0jZC3TnuC3i8MOlnNmoYiPPw7hCu/GrR4tdpRySyq/uaskUzNpYWxIuhB4Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=D8JcCSx2; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=WsZvmPHfN7fPNZg3H2FzpVxdFXo8damEw8Ch/6pQZpc=; b=D8JcCSx2q6237GVwshIIDw2PHf Flo5GVWU0AsstlVbVZfhj1nVe4WFAc+8tCIi7pRJkiM8zlT7x3a0UTtE0Ql2Ix52MRUcT5ynSGXKo NHlOrCIDu8j/fpdUe9te7kj2Or6UtaCLoMDIzX9ttNQ9fbqIb2PjfjP4dXfEvyKUIGfnLdWGrok1I y13oMWL3B/zugTcdOMvI2VnSwU+4BQ9BPIep0VWKcg7WZ90s3YkJrXxRuvQ9/is5Prd7eJMoIKX+q 19f8BDyFIaGzLOKaQBCk1FiXUt9Ko2e25pgLLjkQqV4SyzyyiT5I343JIVueIrMJ3bW0C2D2TbfgO 2RuT8UmA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sET7O-0000000EoxQ-0f7w; Tue, 04 Jun 2024 12:18:22 +0000 Date: Tue, 4 Jun 2024 13:18:22 +0100 From: Matthew Wilcox To: Usama Arif Cc: akpm@linux-foundation.org, 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 v2 1/2] mm: clear pte for folios that are zero filled Message-ID: References: <20240604105950.1134192-1-usamaarif642@gmail.com> <20240604105950.1134192-2-usamaarif642@gmail.com> 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-Disposition: inline In-Reply-To: <20240604105950.1134192-2-usamaarif642@gmail.com> On Tue, Jun 04, 2024 at 11:58:24AM +0100, Usama Arif wrote: > +++ b/mm/rmap.c > @@ -1819,96 +1819,101 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, > */ > dec_mm_counter(mm, mm_counter(folio)); > } else if (folio_test_anon(folio)) { > - swp_entry_t entry = page_swap_entry(subpage); > - pte_t swp_pte; > - /* > - * Store the swap location in the pte. > - * See handle_pte_fault() ... > - */ > - if (unlikely(folio_test_swapbacked(folio) != > - folio_test_swapcache(folio))) { > + if (flags & TTU_ZERO_FOLIO) { > + pte_clear(mm, address, pvmw.pte); > + dec_mm_counter(mm, MM_ANONPAGES); > + } else { This is very hard to review. Is what you've done the same as: if (flags & TTU_ZERO_FOLIO) { pte_clear(mm, address, pvmw.pte); dec_mm_counter(mm, MM_ANONPAGES); goto discard; } ? I genuinely can't tell.