From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BC95C197A0 for ; Thu, 16 Nov 2023 11:01:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbjKPLCA (ORCPT ); Thu, 16 Nov 2023 06:02:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbjKPLB6 (ORCPT ); Thu, 16 Nov 2023 06:01:58 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD7B784 for ; Thu, 16 Nov 2023 03:01:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700132513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=tG/qxV/5LF6QLG8P+GElyJmBVfmO6gfwlWGi3iluUvc=; b=elo/AgAqrJYFiaMuy7hvlBfKxy80zEuLNoMvUx2DpqnBdZSFjjJwZpl12qvox4cWjTGGHN C0KYdjBX5zxvJAzgQ7lvbqZjHueYu8wDrm3tS0mgMyTI5dR5n7P0eGNP3i2JaIfZWWsJbN iMx6cn4nuAXtcl9gFfXqjgvAebfCsi4= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-142-NxFaLoWcNOe_tZhxYa3q-g-1; Thu, 16 Nov 2023 06:01:52 -0500 X-MC-Unique: NxFaLoWcNOe_tZhxYa3q-g-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c50bebd8dfso5756871fa.3 for ; Thu, 16 Nov 2023 03:01:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700132511; x=1700737311; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tG/qxV/5LF6QLG8P+GElyJmBVfmO6gfwlWGi3iluUvc=; b=uynMxjQZQX1L1uca42VazeAbJHeydTpJybvo1/iVWnL7OKafDNd2x+pHOJ0n55+5ck TUIRIufREWxtkQ94gWEIAMcMI49W3DEWqD8CbQLkyfSpXak83GnP1SrJKnwR/6mPGLBj OejMOc5tkmqgiKCMSApuUye3exJODaNrzQTmUWurR5X7JHsJ6CemP04fDDfVNIsvnBfW TA2y2w/aA0OE4e1Jm23rVnG7KIGXETj5sM4k707A7YHTB5h1O/24bA1m2eP10cqIN/vu 7SxUNaAG0gBpzLzKhfmplLB3zvZTzDbfWlc7xLB6En61NZVQ+QOiHYvg+zh7Xi560EDv 9McQ== X-Gm-Message-State: AOJu0YwYkYYenaTo+xH1gcuOfSTDj4nT87lZzo2LIpyzUHlN6U23H3hn xzIMbxgl0AYi08hzJvGPrj/7uPE7b40OtcQ5avdbIEX51NsDejUPjibLMpkO23a1CI82lQmvnHh gK87AaKRAr6LXmIlxC8eboGiF X-Received: by 2002:a2e:b614:0:b0:2c5:19ab:7270 with SMTP id r20-20020a2eb614000000b002c519ab7270mr5817548ljn.35.1700132510921; Thu, 16 Nov 2023 03:01:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvqf40qKivd5cdWSMTAuBPsxwhkl+/VG/CzL9Zy3QxNRhQ92IjLlg+N4q7QmM1XL/OjEMqBQ== X-Received: by 2002:a2e:b614:0:b0:2c5:19ab:7270 with SMTP id r20-20020a2eb614000000b002c519ab7270mr5817507ljn.35.1700132510434; Thu, 16 Nov 2023 03:01:50 -0800 (PST) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id bg3-20020a05600c3c8300b004077219aed5sm3232262wmb.6.2023.11.16.03.01.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Nov 2023 03:01:49 -0800 (PST) Message-ID: <930b5f6a-27d9-43da-bf9f-1478c8de1af8@redhat.com> Date: Thu, 16 Nov 2023 12:01:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 01/14] mm: Batch-copy PTE ranges during fork() Content-Language: en-US To: Ryan Roberts , kernel test robot , Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , Anshuman Khandual , Matthew Wilcox , Yu Zhao , Mark Rutland , Kefeng Wang , John Hubbard , Zi Yan Cc: oe-kbuild-all@lists.linux.dev, Linux Memory Management List , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20231115163018.1303287-2-ryan.roberts@arm.com> <202311160516.kHhfmjvl-lkp@intel.com> <4e8d329c-eda6-4ff8-bb56-8924bb4583b2@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32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UJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16.11.23 11:36, Ryan Roberts wrote: > On 16/11/2023 10:12, David Hildenbrand wrote: >> On 16.11.23 11:07, Ryan Roberts wrote: >>> Hi All, >>> >>> Hoping for some guidance below! >>> >>> >>> On 15/11/2023 21:26, kernel test robot wrote: >>>> Hi Ryan, >>>> >>>> kernel test robot noticed the following build errors: >>>> >>>> [auto build test ERROR on akpm-mm/mm-everything] >>>> [also build test ERROR on linus/master v6.7-rc1 next-20231115] >>>> [cannot apply to arm64/for-next/core efi/next] >>>> [If your patch is applied to the wrong git tree, kindly drop us a note. >>>> And when submitting patch, we suggest to use '--base' as documented in >>>> https://git-scm.com/docs/git-format-patch#_base_tree_information] >>>> >>>> url: >>>> https://github.com/intel-lab-lkp/linux/commits/Ryan-Roberts/mm-Batch-copy-PTE-ranges-during-fork/20231116-010123 >>>> base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git >>>> mm-everything >>>> patch link: >>>> https://lore.kernel.org/r/20231115163018.1303287-2-ryan.roberts%40arm.com >>>> patch subject: [PATCH v2 01/14] mm: Batch-copy PTE ranges during fork() >>>> config: arm-randconfig-002-20231116 >>>> (https://download.01.org/0day-ci/archive/20231116/202311160516.kHhfmjvl-lkp@intel.com/config) >>>> compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0 >>>> reproduce (this is a W=1 build): >>>> (https://download.01.org/0day-ci/archive/20231116/202311160516.kHhfmjvl-lkp@intel.com/reproduce) >>>> >>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of >>>> the same patch/commit), kindly add following tags >>>> | Reported-by: kernel test robot >>>> | Closes: >>>> https://lore.kernel.org/oe-kbuild-all/202311160516.kHhfmjvl-lkp@intel.com/ >>>> >>>> All errors (new ones prefixed by >>): >>>> >>>>     mm/memory.c: In function 'folio_nr_pages_cont_mapped': >>>>>> mm/memory.c:969:16: error: implicit declaration of function 'pte_pgprot'; >>>>>> did you mean 'ptep_get'? [-Werror=implicit-function-declaration] >>>>       969 |         prot = pte_pgprot(pte_mkold(pte_mkclean(ptent))); >>>>           |                ^~~~~~~~~~ >>>>           |                ptep_get >>>>     cc1: some warnings being treated as errors >>> >>> It turns out that pte_pgprot() is not universal; its only implemented by >>> architectures that select CONFIG_HAVE_IOREMAP_PROT (currently arc, arm64, >>> loongarch, mips, powerpc, s390, sh, x86). >>> >>> I'm using it in core-mm to help calculate the number of "contiguously mapped" >>> pages within a folio (note that's not the same as arm64's notion of >>> contpte-mapped. I just want to know that there are N physically contiguous pages >>> mapped virtually contiguously with the same permissions). And I'm using >>> pte_pgprot() to extract the permissions for each pte to compare. It's important >>> that we compare the permissions because just because the pages belongs to the >>> same folio doesn't imply they are mapped with the same permissions; think >>> mprotect()ing a sub-range. >>> >>> I don't have a great idea for how to fix this - does anyone have any thoughts? >> >> KIS :) fork() operates on individual VMAs if I am not daydreaming. >> >> Just check for the obvious pte_write()/dirty/ and you'll be fine. > > Yes, that seems much simpler! I think we might have to be careful about the uffd > wp bit too? I think that's it - are there any other exotic bits that might need > to be considered? Good question. Mimicing what the current code already does should be sufficient. uffd-wp should have the PTE R/O. You can set the contpte bit independent of any SW bit (uffd-wp, softdirty, ...) I guess, no need to worry about that. -- Cheers, David / dhildenb