Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1572561lqt; Wed, 20 Mar 2024 07:59:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX551o+wG+bWTdBYj85S6Nzkp+gEW2uMQ+V/wO+ysoMWRmrbhyYhl5XhTwOwInDVIuWTRrvYJu8jOnqvzXBR8RvL1sxYHPu4rJAdiCTyQ== X-Google-Smtp-Source: AGHT+IGcJNibQm1Onw6TzM0lYjRQPJoF5FyVJgIAXHf6HQJu8Df4OuO2/73Y8ydP8JJINxEMZbDJ X-Received: by 2002:a17:906:1547:b0:a45:b1d8:200c with SMTP id c7-20020a170906154700b00a45b1d8200cmr12555654ejd.14.1710946774581; Wed, 20 Mar 2024 07:59:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710946774; cv=pass; d=google.com; s=arc-20160816; b=P8950A2fmFN4qNnWx+OTTELgQaewqvj38/I/dvSeTM8DpyDehXbjRndJ9ykMeLroFH qTB3TKoYopN5nZ4uFJW0yrZJpgcn5kRuukCeXLgh+AF059oS/Sw2Cjh9FC2IgImZsiMl GYGkOTausOf5B4se2RjOHfH5ZxWnkDUeLBg18eQdIn0PMz6or7l773nfmAP68xkKsmbW qONXvIcXEVt64qyYn/5s8jZebTpMibsl6XjdBFpK2Hc9wDMFuYMj52NO8EpPQE/FNICP GXwJCO4CgSfn2xVcHs6hfmluTChNG0T2yryGC74Qpp0b0YbmQTQQDd2eWqpOlcauQqAY WhYw== 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=Szd1k6J35ASlBha6qDCIcbBM34pxQ+1tlBnb0g8bakY=; fh=ieeEHCSmkFZzD0II1P2iPLHoQdL5rt4/kKBbteAFI8k=; b=jixlJV0nvSWwRDib8LO3a8RRBkcGtGONMtPOmnCCpQF9zca7jFZLyfOz8nb9cvidOl Yo8dvTeVzrHHkZB5nAJ15JxQ8bLp4a+j1h5Andtme5eGoVDQ1Ud+jA2i5K1Y+SBois/s 7pEfYNRFTnBedYm72XtIOrrKmRw1lqBjOZrXQSQ1s2ebQTYNeumHsjn/wC+wod5ILV7b XTMgsOhxFeMEw/7y1NexpL8koIlGZX0FKICHas+zsKsbD77BB4mIFN/7au05c5IRpiDE obDxKD9EnU4iz0Gyc7kNVt7jHWajOi0YAjcfOhyU8GCBMo92czjCoYAZ/LarRRbyV+VH 2saA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EVVWGDMH; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-109050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109050-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 lt8-20020a170906fa8800b00a4679ce18f0si5735871ejb.747.2024.03.20.07.59.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:59:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109050-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=@infradead.org header.s=casper.20170209 header.b=EVVWGDMH; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-109050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109050-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 4DD5B1F2395A for ; Wed, 20 Mar 2024 14:59:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CAD4F4C631; Wed, 20 Mar 2024 14:57:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="EVVWGDMH" 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 17BC94AEF0 for ; Wed, 20 Mar 2024 14:57:17 +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=1710946639; cv=none; b=rz1cx1Ej+x17z1ZGphQFZ5NDqFmErUiQrtwha8gZNUFhWaWUOMmWzyZJnXqy1aVqiqSUiVTTt918NqnstZrbzqfWBPWCY2awg7h9WzLXWO63m8G6Llc5O5hbr72+HufexjlXPeOVjrfVfP4OqyqOY01lJSJkovPZze/X92TXtho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710946639; c=relaxed/simple; bh=jxz90Vwk/KeGSdB2hNfASqxAyf8cA8P0aDldD+//xo4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PcIU1UXRid8DcUVFefm7s85LGnZZPjXAn0Fv90nNWig8dAWINOLws+hg5GTc1aQu0vYDLg388R6JwSpbyriJ8vhYwTSlQC0WUBNOR8GaxtnOCBXkwQoMjHXDCu0ZbVJIkY3EbaInoVBW3k0VfBG3hmiQ3L5bZqhYtnVi5HuqXO0= 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=EVVWGDMH; 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=Szd1k6J35ASlBha6qDCIcbBM34pxQ+1tlBnb0g8bakY=; b=EVVWGDMHntouYHloCKFTSu25qU hLiwXHyWtSPq4aS6Hmp5aUxbm4R7R/zC730IRBc+tZMghRepCk60nZRJF2VJHmiPQy0U/7W4ocxyk l8pUjKGok21IIOKXID0r4WffiNWPtA4rok3tt2oLwx3m+O2LFh4U1Xsg88EyudMLo5afiNoPG9CbX sILZSufHCo1UOuSS0HlLZ/f5kk9sUQQwP6Bg4Ge6V7+EVra9CA1TQT58jW7W0Z0sAewpVghPvn7t4 gei9LJFhbncfTLcClsNHLTMe5rUC0woPmQDBiKsHZ0cTt+3IXeB4WnwjtWoxooWgsns1RAYbVQgAz J+AejQGg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmxNL-00000004Wkk-04sO; Wed, 20 Mar 2024 14:57:07 +0000 Date: Wed, 20 Mar 2024 14:57:06 +0000 From: Matthew Wilcox To: alexs@kernel.org Cc: Izik Eidus , Andrea Arcangeli , Hugh Dickins , Chris Wright , kasong@tencent.com, Andrew Morton , "open list:MEMORY MANAGEMENT" , open list Subject: Re: [PATCH 06/11] mm/ksm: use folio in write_protect_page Message-ID: References: <20240320074049.4130552-1-alexs@kernel.org> <20240320074049.4130552-7-alexs@kernel.org> 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: <20240320074049.4130552-7-alexs@kernel.org> On Wed, Mar 20, 2024 at 03:40:42PM +0800, alexs@kernel.org wrote: > -static int write_protect_page(struct vm_area_struct *vma, struct page *page, > +static int write_protect_page(struct vm_area_struct *vma, struct folio *folio, > pte_t *orig_pte) > { > struct mm_struct *mm = vma->vm_mm; > - DEFINE_PAGE_VMA_WALK(pvmw, page, vma, 0, 0); > + DEFINE_PAGE_VMA_WALK(pvmw, &folio->page, vma, 0, 0); We have a DEFINE_FOLIO_VMA_WALK > - pvmw.address = page_address_in_vma(page, vma); > + pvmw.address = page_address_in_vma(&folio->page, vma); We don't yet have a folio_address_in_vma(). This needs more study, so I approve of how you've converted this line. > - BUG_ON(PageTransCompound(page)); I might make this a VM_BUG_ON(folio_test_large(folio)) > @@ -1505,7 +1503,7 @@ static int try_to_merge_one_page(struct vm_area_struct *vma, > * ptes are necessarily already write-protected. But in either > * case, we need to lock and check page_count is not raised. > */ > - if (write_protect_page(vma, page, &orig_pte) == 0) { > + if (write_protect_page(vma, (struct folio *)page, &orig_pte) == 0) { I don't love this cast. I see why it's safe (called split_huge_page() above), but I'd rather see a call to page_folio() just to keep things tidy.