Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp354088rdb; Thu, 30 Nov 2023 06:40:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/61BsC2rPsr4QQl9GCEIRY3S5xkafCQEDHZegzcBX5cFbqiZm4IaPwpjx097tt1xMa1XA X-Received: by 2002:a05:6a20:9383:b0:18c:43f4:3d44 with SMTP id x3-20020a056a20938300b0018c43f43d44mr18340647pzh.25.1701355203598; Thu, 30 Nov 2023 06:40:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701355203; cv=none; d=google.com; s=arc-20160816; b=dktl+5Uf10+AUJYOLN6XZ6VodqLfwo6kYDawe1lpmNOhR+yS9yfY8yD+FtRuuIbMtH ODNSvxkRchICdWmVWLY5WbUok0TOWTr6dMssa40Na2yIz2XP9j59AT0/0SF4mh7MheLy PehBtdBq01sqzWzL8ALhP5p5dfGH0AuUBkVnFJhKVON2zKRNSNIdS0Cei9fMSYooD8A2 20SAZSyk2aJLLPEsBVtjVgIWO8wIS5g0cLku7S1QKwzWdcaIMBcxaZpEOoKv/LkhhyEH oyOfhvP4RnJjvJ4PuHXQsCSYA50T7x1KBq1aUp2wiry7uCN5+Pz0f2w02dOO7jQxScjj al3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:autocrypt:from:references:cc:to:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature; bh=/AqGlRrDsos2DSPP9yGmIJQFx/oRnqCKEogsu6TRXiA=; fh=C2qC1nYgy4uggpmWFuzeQk9XblOzZlDMkWbGn2+Xz8c=; b=1FKwpqL8aEJ9B/UMSIO28zStRF6kGZNnFIcuefaPT/yKXU5PXmz1zN1RP76eW1NlUK T87PgRutcZrUqBQJ5AR4fCgzvihbshbtWWugV9Qf3Ze9mmI1Tkrtp7+IcnhJOzSO7yEQ Qzmqik/0ChlnSfq72R3lEY+M36d4M/eXQ7uuCs1CGML+sZH3MWuEwMPx5e/GMZuGF8Af 2IjmPYWHBOlRA0Z4jDcaODXoCbCwaBpHDfcvZv35HdRYSMKihWuh0lAuRxGdtNAwxnqG tDXmH+3bRzh/l1JtldsROsei+uCFQ8fdN+2t8eUbgS6TNNZtXAsoLN9/NqRw2ZE5EPmD 5Y4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=I+32t+JZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id t24-20020a656098000000b005b874265d1fsi1415361pgu.513.2023.11.30.06.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 06:40:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=I+32t+JZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id AD83880238A4; Thu, 30 Nov 2023 06:40:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346094AbjK3Ojh (ORCPT + 99 others); Thu, 30 Nov 2023 09:39:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346088AbjK3Ojg (ORCPT ); Thu, 30 Nov 2023 09:39:36 -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 DF26399 for ; Thu, 30 Nov 2023 06:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701355181; 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=/AqGlRrDsos2DSPP9yGmIJQFx/oRnqCKEogsu6TRXiA=; b=I+32t+JZJwVYGToqNKT+HOy1a6lB+8jiFJkRmEVvMZ5YAIaD9Xl/1sDi1shtHuVoHsZcKw xBLjG+/KdmeGAdBwm1L575X690e5XMqEj+pgvxA2MQSB7LVBIJ2pGrhiS8a6P+SIOK5D4N ZSnUJlgSP0WruaJzz+mIV2OixwxXyXE= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-4NSloAD8PLCS_wdVBLYDlA-1; Thu, 30 Nov 2023 09:39:39 -0500 X-MC-Unique: 4NSloAD8PLCS_wdVBLYDlA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40b2977d7c5so8371865e9.2 for ; Thu, 30 Nov 2023 06:39:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701355178; x=1701959978; 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=/AqGlRrDsos2DSPP9yGmIJQFx/oRnqCKEogsu6TRXiA=; b=u15+5LX8zRswD5rgRdK4mzJC+5seMZVArhNUWL2CZFhlf9z51sm6JPjz0d289jvofH X9Bg9uYWeq7o6aBr8wBgp4tYZgXzo9YhswdNZAc9eBMtvrPivXfaI+e0TdyLkMwjmltH hdLgNPmdsQsB3MVDdUDxtKPM4tMb92b5cudlVgd5yaUfgN8dIouzBJMiEKGE0K5snGeh kT2E73C/RRiGU6DFm7peywaP/sQ0JYTrj/PT5O2kBnZoSoKc/wiLnYqE18V7xFXz7rzN pDnUwZIoycMO4Fv6sTTyBqcVHXoARV6wZyQHGYKz6k0wFgamt3s7HDsS85j+oVKaN48z ayDg== X-Gm-Message-State: AOJu0Ywj4Zu/qPnrhCBpi4RVx8+AE0FaXC4RGFhERios08A+KVsAR7p9 /XKuNoiWgz/oc+EbnUudHGgOyAVEpuRjtvSXqqfrfMgq3X3wukFYs7hXAG4wRpTEtzSdY9evNOG Gwd10SdCvi4IL5XNnpuCRQ1f8 X-Received: by 2002:adf:ef0c:0:b0:332:c9eb:87dc with SMTP id e12-20020adfef0c000000b00332c9eb87dcmr13849326wro.44.1701355177839; Thu, 30 Nov 2023 06:39:37 -0800 (PST) X-Received: by 2002:adf:ef0c:0:b0:332:c9eb:87dc with SMTP id e12-20020adfef0c000000b00332c9eb87dcmr13849292wro.44.1701355177396; Thu, 30 Nov 2023 06:39:37 -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 r4-20020adff104000000b003313e4dddecsm1698979wro.108.2023.11.30.06.39.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Nov 2023 06:39:36 -0800 (PST) Message-ID: <92833873-cd70-44b0-9f34-f4ac11b9e498@redhat.com> Date: Thu, 30 Nov 2023 15:39:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC v2 19/27] mm: mprotect: Introduce PAGE_FAULT_ON_ACCESS for mprotect(PROT_MTE) Content-Language: en-US To: Alexandru Elisei Cc: Hyesoo Yu , catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com, pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, eugenis@google.com, kcc@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org References: <20231119165721.9849-1-alexandru.elisei@arm.com> <20231119165721.9849-20-alexandru.elisei@arm.com> <20231129092725.GD2988384@tiffany> <4e7a4054-092c-4e34-ae00-0105d7c9343c@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/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foUTv03iO9El5f 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: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 06:40:00 -0800 (PST) On 30.11.23 15:33, Alexandru Elisei wrote: > On Thu, Nov 30, 2023 at 02:43:48PM +0100, David Hildenbrand wrote: >> On 30.11.23 14:32, Alexandru Elisei wrote: >>> Hi, >>> >>> On Thu, Nov 30, 2023 at 01:49:34PM +0100, David Hildenbrand wrote: >>>>>>> + >>>>>>> +out_retry: >>>>>>> + put_page(page); >>>>>>> + if (vmf->flags & FAULT_FLAG_VMA_LOCK) >>>>>>> + vma_end_read(vma); >>>>>>> + if (fault_flag_allow_retry_first(vmf->flags)) { >>>>>>> + err = VM_FAULT_RETRY; >>>>>>> + } else { >>>>>>> + /* Replay the fault. */ >>>>>>> + err = 0; >>>>>> >>>>>> Hello! >>>>>> >>>>>> Unfortunately, if the page continues to be pinned, it seems like fault will continue to occur. >>>>>> I guess it makes system stability issue. (but I'm not familiar with that, so please let me know if I'm mistaken!) >>>>>> >>>>>> How about migrating the page when migration problem repeats. >>>>> >>>>> Yes, I had the same though in the previous iteration of the series, the >>>>> page was migrated out of the VMA if tag storage couldn't be reserved. >>>>> >>>>> Only short term pins are allowed on MIGRATE_CMA pages, so I expect that the >>>>> pin will be released before the fault is replayed. Because of this, and >>>>> because it makes the code simpler, I chose not to migrate the page if tag >>>>> storage couldn't be reserved. >>>> >>>> There are still some cases that are theoretically problematic: vmsplice() >>>> can pin pages forever and doesn't use FOLL_LONGTERM yet. >>>> >>>> All these things also affect other users that rely on movability (e.g., CMA, >>>> memory hotunplug). >>> >>> I wasn't aware of that, thank you for the information. Then to ensure that the >>> process doesn't hang by replying the loop indefinitely, I'll migrate the page if >>> tag storage cannot be reserved. Looking over the code again, I think I can reuse >>> the same function that migrates tag storage pages out of the MTE VMA (added in >>> patch #21), so no major changes needed. >> >> It's going to be interesting if migrating that page fails because it is >> pinned :/ > > I imagine that having both the page **and** its tag storage pinned longterm > without FOLL_LONGTERM is going to be exceedingly rare. Yes. I recall that the rule of thumb is that some O_DIRECT I/O can take up to 10 seconds, although extremely rare (and maybe not applicable on arm64). > > Am I mistaken in believing that the problematic vmsplice() behaviour is > recognized as something that needs to be fixed? Yes, for a couple of years I'm hoping this will actually get fixed now that O_DIRECT mostly uses FOLL_PIN instead of FOLL_GET. -- Cheers, David / dhildenb