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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9638EC4345F for ; Wed, 24 Apr 2024 21:01:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B74E8D0033; Wed, 24 Apr 2024 17:01:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2664D8D0031; Wed, 24 Apr 2024 17:01:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 106E08D0033; Wed, 24 Apr 2024 17:01:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E8B188D0031 for ; Wed, 24 Apr 2024 17:01:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A4C1FA174A for ; Wed, 24 Apr 2024 21:01:05 +0000 (UTC) X-FDA: 82045645290.26.1FA9851 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 6E6DD4000E for ; Wed, 24 Apr 2024 21:01:03 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RniFljQI; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713992463; h=from:from:sender: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:dkim-signature; bh=pwf1N0pqao7hHUJlsTVeqzeGDUAlXHRYWippfBfxMg0=; b=f8yNOF/coUClT9rEenkpLZeuy2FTsWndiMPNux/D9fW4/UVoU80oNX2u4wsoAU2ure8J38 km9gu9dSyIrKDzieL4wGA4Jpm4ECMF0EfGmCAEQwGIHpiuKZ+rR6srtcOkppJKVQG4sxcl jwNEQUO7hU5phoREh0VdxCLJsH0MOWg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713992463; a=rsa-sha256; cv=none; b=b8t5tghK4il/W+7c2cKRbMmE2NX/lAvFzHFWbQ5xcm+/F0LBuqsGKnVGW1vk+1dqvdXYYc mDBSrEYeIfKoQkjgPfUgeHM5dzk/2LmR4GQ3CL7cBol7KY05jNUTgWzTxDE2m3izxm6BM8 540hFfbkHyu07Exze6j7pUi2N6Va8ns= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RniFljQI; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713992462; 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=pwf1N0pqao7hHUJlsTVeqzeGDUAlXHRYWippfBfxMg0=; b=RniFljQItq4yVgPXvZpH1GhndWJEFRgc5e/22ObQ7p8hM4KZAweVNX2SuMmIHtyzL5lpR9 vce979u6Do8atzyhrn8C1/Gds6k5TW269Q8hUUkpBTh+mGgE3GxuAR/zjvqqy4uD8S0xtF rb81y0l5ZLPrpAPHXPMXEhrxO5e2jiQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-ywJtIiiiOaq_diWVj8tI6w-1; Wed, 24 Apr 2024 17:01:01 -0400 X-MC-Unique: ywJtIiiiOaq_diWVj8tI6w-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4147de378b9so1066225e9.3 for ; Wed, 24 Apr 2024 14:01:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713992156; x=1714596956; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pwf1N0pqao7hHUJlsTVeqzeGDUAlXHRYWippfBfxMg0=; b=VU29qg7ByrxQ8SdBaK27PSp7bhW4nW5dqbZ4ybwtWjb/01kzLjXgM5RpYKJiV2lFum S1k6nqUabnT1FdYTuBOQakiTOczELavm5zMbR5ThIaoDksfPQeixjU51QjvmZw+naLHs CYpQURCu0bf0Gn8OoHhtfa7HMy4QiX2OVwsZ619/FuvnSbcrVtpOD9MQ42TvmM1p7MmJ yoId+vxlZjep1Ngwts+KI9lA8TGoB8BDtQnaec/wPILWNT7vtehZbxG9FqyhXE1A3v25 DloONeoasoHQG94ObVA4Mxi75U5CXHQ5+MdA/pk6gLRT2a/US6ntx3aNLGszL04t6vrv PVsw== X-Forwarded-Encrypted: i=1; AJvYcCUQDxd5++AgR8+WjmZXZtLBR9ek0GV8doqsxS5zG7gooUQFTe/bCUP4AI89i8fAMkTniMBKqOGXrQaSs5oNUlBGQ80= X-Gm-Message-State: AOJu0YypDXJczPRmDeo/+B+0+yC2j7r4lJSIFn2bNeuHVNdLx7u9mZLH HlF4SClF1wpbgpJdhVggxfpoMHUaj8QWOxDrOtcMAiuL/9sjkqLDTv/gVc+Zziad7+OarpMh2+g IaApRPeUGYaPInajlk0ig0ulHv46dcTRKE2O2h3OYy1NybLj8 X-Received: by 2002:a05:600c:190d:b0:418:fea2:ed94 with SMTP id j13-20020a05600c190d00b00418fea2ed94mr2750201wmq.23.1713992156329; Wed, 24 Apr 2024 13:55:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEozGXAqQGOfJt3u+VhzyJaF4t4KYaq0an+quDHunqz+3ck5Ll/n4JuxU/7P2GqC7u7V0lcbQ== X-Received: by 2002:a05:600c:190d:b0:418:fea2:ed94 with SMTP id j13-20020a05600c190d00b00418fea2ed94mr2750193wmq.23.1713992155893; Wed, 24 Apr 2024 13:55:55 -0700 (PDT) Received: from ?IPV6:2003:cb:c70d:1f00:7a4e:8f21:98db:baef? (p200300cbc70d1f007a4e8f2198dbbaef.dip0.t-ipconnect.de. [2003:cb:c70d:1f00:7a4e:8f21:98db:baef]) by smtp.gmail.com with ESMTPSA id je12-20020a05600c1f8c00b004183edc31adsm28634639wmb.44.2024.04.24.13.55.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Apr 2024 13:55:55 -0700 (PDT) Message-ID: <04137a08-8918-422c-8512-beb2074a427e@redhat.com> Date: Wed, 24 Apr 2024 22:55:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v21 2/5] ring-buffer: Introducing ring-buffer mapping functions To: Vincent Donnefort Cc: rostedt@goodmis.org, mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, kernel-team@android.com, rdunlap@infradead.org, rppt@kernel.org, linux-mm@kvack.org References: <20240423232728.1492340-1-vdonnefort@google.com> <20240423232728.1492340-3-vdonnefort@google.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhh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oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+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: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6E6DD4000E X-Rspam-User: X-Stat-Signature: ptqyf9yrhc6x7g51ytq7ikksgd3qqppu X-HE-Tag: 1713992463-155628 X-HE-Meta: U2FsdG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pPZgzH8MDj+tFgDhuDJOXonh7OvB0s9VJb2lndKMrv1Ov2CdDbiiwQj5x5fsHSnQsweZEZBxahn6JJFF9tNVIEB1ojS94= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 24.04.24 22:31, Vincent Donnefort wrote: > Hi David, > > Thanks for your quick response. > > On Wed, Apr 24, 2024 at 05:26:39PM +0200, David Hildenbrand wrote: >> >> I gave it some more thought, and I think we are still missing something (I >> wish PFNMAP/MIXEDMAP wouldn't be that hard). >> >>> + >>> +/* >>> + * +--------------+ pgoff == 0 >>> + * | meta page | >>> + * +--------------+ pgoff == 1 >>> + * | subbuffer 0 | >>> + * | | >>> + * +--------------+ pgoff == (1 + (1 << subbuf_order)) >>> + * | subbuffer 1 | >>> + * | | >>> + * ... >>> + */ >>> +#ifdef CONFIG_MMU >>> +static int __rb_map_vma(struct ring_buffer_per_cpu *cpu_buffer, >>> + struct vm_area_struct *vma) >>> +{ >>> + unsigned long nr_subbufs, nr_pages, vma_pages, pgoff = vma->vm_pgoff; >>> + unsigned int subbuf_pages, subbuf_order; >>> + struct page **pages; >>> + int p = 0, s = 0; >>> + int err; >>> + >> >> I'd add some comments here like >> >> /* Refuse any MAP_PRIVATE or writable mappings. */ >>> + if (vma->vm_flags & VM_WRITE || vma->vm_flags & VM_EXEC || >>> + !(vma->vm_flags & VM_MAYSHARE)) >>> + return -EPERM; >>> + >> >> /* >> * Make sure the mapping cannot become writable later. Also, tell the VM >> * to not touch these pages pages (VM_DONTCOPY | VM_DONTDUMP) and tell >> * GUP to leave them alone as well (VM_IO). >> */ >>> + vm_flags_mod(vma, >>> + VM_MIXEDMAP | VM_PFNMAP | >>> + VM_DONTCOPY | VM_DONTDUMP | VM_DONTEXPAND | VM_IO, >>> + VM_MAYWRITE); >> >> I am still really unsure about VM_PFNMAP ... it's not a PFNMAP at all and, >> as stated, vm_insert_pages() even complains quite a lot when it would have >> to set VM_MIXEDMAP and VM_PFNMAP is already set, likely for a very good >> reason. >> >> Can't we limit ourselves to VM_IO? >> >> But then, I wonder if it really helps much regarding GUP: yes, it blocks >> ordinary GUP (see check_vma_flags()) but as insert_page_into_pte_locked() >> does *not* set pte_special(), GUP-fast (gup_fast_pte_range()) will not >> reject it. >> >> Really, if you want GUP-fast to reject it, remap_pfn_range() and friends are >> the way to go, that will set pte_special() such that also GUP-fast will >> leave it alone, just like vm_normal_page() would. >> >> So ... I know Linus recommended VM_PFNMAP/VM_IO to stop GUP, but it alone >> won't stop all of GUP. We really have to mark the PTE as special, which >> vm_insert_page() must not do (because it is refcounted!). > > Hum, apologies, I am not sure to follow the connection here. Why do you think > the recommendation was to prevent GUP? Ah, I'm hallucinating! :) "not let people play games with the mapping" to me implied "make sure nobody touches it". If GUP is acceptable that makes stuff a lot easier. VM_IO will block some GUP, but not all of it. > >> >> Which means: do we really have to stop GUP from grabbing that page? >> >> Using vm_insert_page() only with VM_MIXEDMAP (and without VM_PFNMAP|VM_IO) >> would be better. > > Under the assumption we do not want to stop all GUP, why not using VM_IO over > VM_MIXEDMAP which is I believe more restrictive? VM_MIXEDMAP will be implicitly set by vm_insert_page(). There is a lengthy comment for vm_normal_page() that explains all this madness. VM_MIXEDMAP is primarily relevant for COW mappings, which you just forbid completely. remap_pfn_range_notrack() documents the semantics of some of the other flags: * VM_IO tells people not to look at these pages * (accesses can have side effects). * VM_PFNMAP tells the core MM that the base pages are just * raw PFN mappings, and do not have a "struct page" associated * with them. * VM_DONTEXPAND * Disable vma merging and expanding with mremap(). * VM_DONTDUMP * Omit vma from core dump, even when VM_IO turned off. VM_PFNMAP is very likely really not what we want, unless we really perform raw PFN mappings ... VM_IO we can set without doing much harm. So I would suggest dropping VM_PFNMAP when using vm_insert_pages(), using only VM_IO and likely just letting vm_insert_pages() set VM_MIXEDMAP for you. [...] >> >> vm_insert_pages() documents: "In case of error, we may have mapped a subset >> of the provided pages. It is the caller's responsibility to account for this >> case." >> >> Which could for example happen, when allocating a page table fails. >> >> Would we able to deal with that here? > > As we are in the mmap path, on an error, I would expect the vma to be destroyed > and those pages whom insertion succeeded to be unmapped? > Ah, we simply fail ->mmap(). In mmap_region(), if call_mmap() failed, we "goto unmap_and_free_vma" where we have /* Undo any partial mapping done by a device driver. */ unmap_region(mm, &vmi.mas, vma, prev, next, vma->vm_start, vma->vm_end, vma->vm_end, true); > But perhaps shall we proactively zap_page_range_single()? No mmap_region() should indeed be handling it correctly already! -- Cheers, David / dhildenb