Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2949471lqo; Tue, 21 May 2024 02:06:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHHuaEis8flJVq0qvV9etD8GfxVTwq+zxPRLOjsgtCiskvT9SUTOB1jb3RsqecMMFNojPT3PS/ygMxl24cP2IKpJrIC/Y/6OcuBYv8/w== X-Google-Smtp-Source: AGHT+IEnNK3A/ExjYOGkosGMalfLYyFNmZFV3s+Z/tZP24j8JBzxkN9i7rzqylFAiJbJqBpFC0FQ X-Received: by 2002:a17:906:4899:b0:a5a:5634:a83a with SMTP id a640c23a62f3a-a5a5634a8abmr1649979966b.17.1716282397265; Tue, 21 May 2024 02:06:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716282397; cv=pass; d=google.com; s=arc-20160816; b=HtdUWR9dFi50blmGmFGAkoLCydNmwzVuNMjCoE2IsvESz698yjLZ30cF8BVROnAGnH cfhGpWg8L8xRHVO9Y7P8I3jJyDNNWjuMPNP0Az29P+uUo/TjU2+GVq8qnVqhWhYyEMpw rpz39pY0kDnhqXBxx3DRNTCrf/juPTLoXSLwk1LmFjlW3aeqt4bYKuUwugR4BWoG/Ar1 Sn11DFaO4E30Mh/wWU/zyI4l9t4MpXxN5/7KUmD+gSSrCgfqtg2xaKuYOyFLsykKUjHr JymFrjSFAWmnQOzxCdNIqVm58/W+lal13aLNTNyFlHAPGk3hcljch52oyqQy+A5DsZof 4/fg== 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=WMYY1KE/ZtKqUz0lxLzk49TxJFJt2lbdNgplL1dA484=; fh=dnCxPEuZEuZ3Xg+gppyx+yUhyaDQSgzfdS0tpYTMFFs=; b=Dvz4REJ6TN5fhpxd9RFVBOKb58QFWFU5QXO43pIQyhbwVhlw6udTkRmb/1RedWrejc 1ztBDxtD1pxj9mcWewkLEewbnJloXBpmdfmszfhkC1dMe47fsXrj40WhU9/KUlf20IMw qBMqFBMasakoIDog4ScT3BhlybOZcXsDIulg8nBLXUrLEftEt6XffZ8VDoB6a6dnCTXP s2XuH+UBhR4R/CUP70+vBYQ4+lYbQk7VI3EjXC7WHr3BY4DmqBTbouXvSZiN75yqce0T OqVS1gVTfFneD6fKaqKsBokvJVrzuTUZ3vFRJrDnopJNozIZPs8hoIo1njEK9wZGodmU iP0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cfDtXDG0; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-184680-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184680-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17be8becsi1379546866b.871.2024.05.21.02.06.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 02:06:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184680-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=@google.com header.s=20230601 header.b=cfDtXDG0; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-184680-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184680-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 06D451F22B47 for ; Tue, 21 May 2024 09:06:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14CB256771; Tue, 21 May 2024 09:06:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cfDtXDG0" Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 A0FE52209F for ; Tue, 21 May 2024 09:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716282388; cv=none; b=tL3WzqZuKx/pHhBh1gpr/Hnc4SabesDiKl3mgAZTVGOC+85C3u6Py+rPKKdyyAK0gqzUq3b7xgXP5GyYpF2Wmcmjw/aQCo5YnJ94ZfSbaVWmJYQIvbuFa5XXtgj2dnTA6itDlJfGHysW7/B/UdHxZ2xbQfGKpGfuSlBUKtAMLnY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716282388; c=relaxed/simple; bh=bsAhFihn815vBtTHR8DbQhKVT37veYmF+S7PhbmBdXM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bdOKY3kisZXf1JC2zMiIFbTmUELeAYJMbQpneiVudemF/+4vmyp9/e8JVIc7GJY6hVQnA0d+8q2cgAVo6ln4PublzJnei7yagB3K+QeZdE7wuJDbNN0xVoS0lRLeQWMDXCigSD4BvsqRd+FqsSRcZ2Dsq7UnIJx4zqKb88efAiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cfDtXDG0; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-354cd8da8b9so787857f8f.0 for ; Tue, 21 May 2024 02:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716282385; x=1716887185; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WMYY1KE/ZtKqUz0lxLzk49TxJFJt2lbdNgplL1dA484=; b=cfDtXDG099m9goonTvN5W8iYXDbnqWN6IoWRMRIymvSVEzsRctnmgnFV7C0LTg9i6Z sOiDlxDJSS7/wT7Sj+iros54L9ejCYkPeIP4SosF216bX6Q1jgibfM64IhO58lBgbTr1 aymGocrJeszB6sm4I2w2AQt93hGxdc5SEt5bC3f5BWQQThqlMGK1xccWcHhP/RdZbGTp 75CYoPqvnE4hzVtpHqwxhhjzHzXwM9nrQjL4soE1T5S4pX34RVurXJlymYbPBxC3ULL6 WqXkR5yYTIT9/gdypWYFOOXhMV/NwfUdZyum0vsQJSGr8Ycr9GDW6e2bloljmva1aLXU s96Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716282385; x=1716887185; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WMYY1KE/ZtKqUz0lxLzk49TxJFJt2lbdNgplL1dA484=; b=cllsMTYFWTxVymo3odKkTrbcqQCu2Dvkkkz9KznAJTP0TCsYGKg9h/g/2qpUChkUso jB2snqooSX4PmKEKFdvSKtqjdGMx+goZFsfikunGwyXJJpyOREmiwwKJfC91UvHqJgCp +X1flkQTCEhRlsPXMUOMCo44kqbwuFj+y0TANT39p56MBdWd55ICDCn+nhh55xFGO6mH yrP0S4onJdJjAH19sLS9vYjenHRgwGOiLSZACFxAGLpVBqKVsPisQquvKRSqV769RrOJ /4xIzmbFaRtUKdIjKsNl4Jmte2bSb0LffZ0HkqJ8GjFhvlR3wNW479g3e9kT0tYAqI2N qwyA== X-Gm-Message-State: AOJu0YzZjDyCIAzFKacxpRt3NJD/fYrURSM69HvA1uOfrFSZ2H4sDMz0 0VQiF32/lGet09/rPXcz8Zj/goxmwEI9xCKny16J5xuVKDoj6j7q02MgH4MZhg== X-Received: by 2002:a5d:698d:0:b0:34d:354:b9ba with SMTP id ffacd0b85a97d-3504a73e32dmr21835351f8f.30.1716282384666; Tue, 21 May 2024 02:06:24 -0700 (PDT) Received: from google.com (65.0.187.35.bc.googleusercontent.com. [35.187.0.65]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b79bdbcsm31255495f8f.23.2024.05.21.02.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 02:06:24 -0700 (PDT) Date: Tue, 21 May 2024 10:06:20 +0100 From: Vincent Donnefort To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Dan Williams , rostedt@goodmis.org Subject: Re: [PATCH v1 1/2] mm/memory: cleanly support zeropage in vm_insert_page*(), vm_map_pages*() and vmf_insert_mixed() Message-ID: References: <20240430204044.52755-1-david@redhat.com> <20240430204044.52755-2-david@redhat.com> <3decc6c8-9035-44d6-89c6-8d42a5e0bc40@redhat.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: <3decc6c8-9035-44d6-89c6-8d42a5e0bc40@redhat.com> On Tue, May 21, 2024 at 10:25:43AM +0200, David Hildenbrand wrote: > On 17.05.24 17:07, Vincent Donnefort wrote: > > Hi David, > > > > [...] > > > > > -static int validate_page_before_insert(struct page *page) > > > +static bool vm_mixed_zeropage_allowed(struct vm_area_struct *vma) > > > +{ > > > + VM_WARN_ON_ONCE(vma->vm_flags & VM_PFNMAP); > > > + /* > > > + * Whoever wants to forbid the zeropage after some zeropages > > > + * might already have been mapped has to scan the page tables and > > > + * bail out on any zeropages. Zeropages in COW mappings can > > > + * be unshared using FAULT_FLAG_UNSHARE faults. > > > + */ > > > + if (mm_forbids_zeropage(vma->vm_mm)) > > > + return false; > > > + /* zeropages in COW mappings are common and unproblematic. */ > > > + if (is_cow_mapping(vma->vm_flags)) > > > + return true; > > > + /* Mappings that do not allow for writable PTEs are unproblematic. */ > > > + if (!(vma->vm_flags & (VM_WRITE | VM_MAYWRITE))) > > > + return false; > > > > Shouldn't we return true here? > > Indeed, thanks! I wish we would have user in the tree already that could > exercise that code path. I have a patch ready to use this path from the memory map tracing! I can either send it once this one is picked-up or you can add it to your series? > > [...] > > > > @@ -2043,7 +2085,7 @@ static int insert_page_in_batch_locked(struct vm_area_struct *vma, pte_t *pte, > > > if (!page_count(page)) > > > return -EINVAL; > > > > This test here prevents inserting the zero-page. > > You mean the existing page_count() check? or the (wrong) vma->vm_flags check > in vm_mixed_zeropage_allowed() ? I meant this page_count() here. As a quick test, I removed that check (also fixed the vm_flags above) and the zero-page was properly mapped! > > -- > Cheers, > > David / dhildenb >