Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp641846lqh; Fri, 31 May 2024 11:38:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRflqwbC4BW63+rNKlP36XA3Jc7aa0HUMMS8sO+H7VSgpLG74y2YhrkHhTTXh7sjDuOcZ0iKUqCA2tya5b6rhNuWNchUEBhPTKBz+yDw== X-Google-Smtp-Source: AGHT+IG09gX9MG3YL/u1rzA2iXBNYMXvNcUGf/Yt5P9W9/OWfEsj/VYvknEYBGrfMOVlRovIf3JG X-Received: by 2002:a05:6a00:4b41:b0:6e8:f708:4b09 with SMTP id d2e1a72fcca58-70247803b39mr3069383b3a.15.1717180736223; Fri, 31 May 2024 11:38:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717180736; cv=pass; d=google.com; s=arc-20160816; b=wUO/BU0cBb62NIBycuTlAQ9E3bH/W5uVJhaZZf3khp+Dk3hIEmokMGYcS2whi2TkCu yiI+M98THOCKOjnFPLLeQX+cwufrGnqNoNr87FfP1BqITyrHOF1XKnklIAXK4HjCMq8F FCANJaG2jat4S5sXQwrpu2s2F1uUKR+q8ME88vWLjr6scpPRSyhRK8LNwTVCQQtfB9M6 vsh6o4OQ8XoEHXKEVIdqjsVF2K1UnKnLHG/YRhfiQ+X4ioOqOnLBt88mhcGVTcv8uniE ePGFibXC00Qau05kv6eyMa6EH90Agbo9nzVsPy78ocXe9CeXdSptVsPiJDicYBBGWUi1 LdsQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=iKg+jpln7A8vhODItQJu8TlGcCL7FlyTgrtCstM6y9E=; fh=9p/CacSwfkz0+zX5BtTf/xKF+XBGQYEMWhpCUktL0QA=; b=Momw4OgxqQ4ZHIcycPGf/o7YvOE/aZzMP1fxR8LhsYYKb0gA8mh1ON50zaTTQM2Kt/ JLPTMcXH0qkc9gU7NsdnCbGUEVvAPGa9IlbGZUtUuSwqJbPLJg4AHVOFBqgJdczoR6UD fe2RLxbIdV0gGfVDKGWmt4AHNstPTUFEYProgFOABUlazOeZRwgjo/m8dfi0JM+VNJ0O CN5ZrvOxyq97Ep7j4jIggPtCm8PhXorzJ3WPualzuEf5YIFHwrYijVgJcCal9gmfwgpL qHuUMMpCilvQugxEkGwAINk0RrQzCe2uhqAsORUbbRzK5f+Ma5v/w+7VyeXqd5vVjd9K tFag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Oknd0hc1; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-197308-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197308-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-70242b07c46si2001722b3a.222.2024.05.31.11.38.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 11:38:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197308-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Oknd0hc1; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-197308-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197308-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5D1C4281AE2 for ; Fri, 31 May 2024 18:38:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B0AA80C0C; Fri, 31 May 2024 18:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Oknd0hc1" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 F11B67E591 for ; Fri, 31 May 2024 18:38:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717180697; cv=none; b=iExDIOS9gF9BLo72STOpq76YWbOnt7jM2rHN9OXmPQinhEjjrx6UGg3WLQG9GfegKniZEY9Wq5YqdH1rHR88W2mnZWt5ZWU/tCulydjkEbS504eWapCXkcX0c6jJk1H8tXRcWVTacrCJMhvXo+EcTF89AhkUj3amxwP73iVU1d0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717180697; c=relaxed/simple; bh=Z24nPTc5WNU09mDYrBR9lmqdOWtHhvWNWIsggI9bdPc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l5iGAVnUufBKf0YOjV+tCLYiO3isQ9Rb3DCIZ60tAIJtb+Dum6HBvOyPeQORkh8CYVWYiu6qc7iuAzMcOFg70aeLdjFUaX5TgMRIyBeorsVh3puZ3AzIP3mvFN2LXLOjRvkYDd2IlqNSlFqPpFi3hj4ZUBTLYnR/+A+jCis9uoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Oknd0hc1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717180695; 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=iKg+jpln7A8vhODItQJu8TlGcCL7FlyTgrtCstM6y9E=; b=Oknd0hc16tQxxJpTTnOWT6wRip/NchsAgmJoT2XwYSzheaNqQmyZcov5aTg49X9LO1x5JF ZlrDT4tvIohef6lr/gv6UsijVlQ9uwxV2DpvnDIx1co7tpelIZdxmbkpz0sxnrIAQTNyUL X2J8Z2T7YU2rAQBH7b1G49qSf8gB3BA= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-264-fYyy4nV-OFu1p3LsGgN4_w-1; Fri, 31 May 2024 14:38:13 -0400 X-MC-Unique: fYyy4nV-OFu1p3LsGgN4_w-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35e0f8bcc3cso490472f8f.2 for ; Fri, 31 May 2024 11:38:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717180692; x=1717785492; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from: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=iKg+jpln7A8vhODItQJu8TlGcCL7FlyTgrtCstM6y9E=; b=XN0HXCl0wBCfAUbVBJHrn2X86BOLyEnPpVO6EfwfiyH2xq1K5Q68kxO5AY+dRPLTp+ 6HOUaQo6zMd+RxVhSU7YLuKKHx3PJIwgxisEEj5e8EaDZCLojvDo1a97naies1m3kArr AYGOFR3jUwMOHt3BUKHslzHKo4yyaSze8zUbYJUhbkeZMjYUJarBeSdmH4C14u6K+R+p +VoNoW0RuYcNnz52zNPFnEoMKrJ7cwNcTkGcDtABJN7GpiTYJsEbeQRnMsni8jAFQ1pg aV+y4GRWypqhU3MgSqny5wtE53xahnoufaGG9BHUU2igMeevv++3YGBAvaFcFDY0J7bS sJ3w== X-Forwarded-Encrypted: i=1; AJvYcCUMmRz1QNQ4HMj4GpWOJFgjoTRUAK17WUKVPVmZciAe2AkRPY66cII8TYirgyxuZ6F/9z70EzS0zijqzWeBMCdfIfRUB5vI3PW7ybME X-Gm-Message-State: AOJu0YwxBOrTvmUHLZaaCqGau3d+gA17QeW0mNFRpCBt5GEKco6sYccv E5rP0E3CBCLnSCYQS4G9QSVxvv76CJ/NSmcZvYpqYB9d1gkVT+HD1CTbjoZ7vbjP1Pyiho8M+SW gMq9bwC00EpqUuKfk5cflJc0+ubZag1sTK3FhG6p1r37uZks3q4+PMVFFdFwt3Q== X-Received: by 2002:a5d:5229:0:b0:34d:95f:c46 with SMTP id ffacd0b85a97d-35e0f32d5c4mr2081238f8f.59.1717180691759; Fri, 31 May 2024 11:38:11 -0700 (PDT) X-Received: by 2002:a5d:5229:0:b0:34d:95f:c46 with SMTP id ffacd0b85a97d-35e0f32d5c4mr2081223f8f.59.1717180691185; Fri, 31 May 2024 11:38:11 -0700 (PDT) Received: from [192.168.3.108] (p5b0c6f0d.dip0.t-ipconnect.de. [91.12.111.13]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd0659bbbsm2396801f8f.110.2024.05.31.11.38.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 May 2024 11:38:10 -0700 (PDT) Message-ID: Date: Fri, 31 May 2024 20:38:09 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [linus:master] [mm] efa7df3e3b: kernel_BUG_at_include/linux/page_ref.h To: Yang Shi Cc: kernel test robot , Peter Xu , Jason Gunthorpe , Vivek Kasireddy , Rik van Riel , oe-lkp@lists.linux.dev, lkp@intel.com, linux-kernel@vger.kernel.org, Andrew Morton , Matthew Wilcox , Christopher Lameter , linux-mm@kvack.org References: <202405311534.86cd4043-lkp@intel.com> <890e5a79-8574-4a24-90ab-b9888968d5e5@redhat.com> From: David Hildenbrand Content-Language: en-US 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/ztJIQqsE5LsUomE//bLwzj9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IMduZ2+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 On 31.05.24 20:30, Yang Shi wrote: > On Fri, May 31, 2024 at 11:24 AM David Hildenbrand wrote: >> >> On 31.05.24 20:13, Yang Shi wrote: >>> On Fri, May 31, 2024 at 11:07 AM Yang Shi wrote: >>>> >>>> On Fri, May 31, 2024 at 10:46 AM David Hildenbrand wrote: >>>>> >>>>> On 31.05.24 18:50, Yang Shi wrote: >>>>>> On Fri, May 31, 2024 at 1:24 AM kernel test robot wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> Hello, >>>>>>> >>>>>>> kernel test robot noticed "kernel_BUG_at_include/linux/page_ref.h" on: >>>>>>> >>>>>>> commit: efa7df3e3bb5da8e6abbe37727417f32a37fba47 ("mm: align larger anonymous mappings on THP boundaries") >>>>>>> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master >>>>>>> >>>>>>> [test failed on linus/master e0cce98fe279b64f4a7d81b7f5c3a23d80b92fbc] >>>>>>> [test failed on linux-next/master 6dc544b66971c7f9909ff038b62149105272d26a] >>>>>>> >>>>>>> in testcase: trinity >>>>>>> version: trinity-x86_64-6a17c218-1_20240527 >>>>>>> with following parameters: >>>>>>> >>>>>>> runtime: 300s >>>>>>> group: group-00 >>>>>>> nr_groups: 5 >>>>>>> >>>>>>> >>>>>>> >>>>>>> compiler: gcc-13 >>>>>>> test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G >>>>>>> >>>>>>> (please refer to attached dmesg/kmsg for entire log/backtrace) >>>>>>> >>>>>>> >>>>>>> we noticed the issue does not always happen. 34 times out of 50 runs as below. >>>>>>> the parent is clean. >>>>>>> >>>>>>> 1803d0c5ee1a3bbe efa7df3e3bb5da8e6abbe377274 >>>>>>> ---------------- --------------------------- >>>>>>> fail:runs %reproduction fail:runs >>>>>>> | | | >>>>>>> :50 68% 34:50 dmesg.Kernel_panic-not_syncing:Fatal_exception >>>>>>> :50 68% 34:50 dmesg.RIP:try_get_folio >>>>>>> :50 68% 34:50 dmesg.invalid_opcode:#[##] >>>>>>> :50 68% 34:50 dmesg.kernel_BUG_at_include/linux/page_ref.h >>>>>>> >>>>>>> >>>>>>> >>>>>>> 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-lkp/202405311534.86cd4043-lkp@intel.com >>>>>>> >>>>>>> >>>>>>> [ 275.267158][ T4335] ------------[ cut here ]------------ >>>>>>> [ 275.267949][ T4335] kernel BUG at include/linux/page_ref.h:275! >>>>>>> [ 275.268526][ T4335] invalid opcode: 0000 [#1] KASAN PTI >>>>>>> [ 275.269001][ T4335] CPU: 0 PID: 4335 Comm: trinity-c3 Not tainted 6.7.0-rc4-00061-gefa7df3e3bb5 #1 >>>>>>> [ 275.269787][ T4335] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 >>>>>>> [ 275.270679][ T4335] RIP: 0010:try_get_folio (include/linux/page_ref.h:275 (discriminator 3) mm/gup.c:79 (discriminator 3)) >>>>>>> [ 275.271159][ T4335] Code: c3 cc cc cc cc 44 89 e6 48 89 df e8 e4 54 11 00 eb ae 90 0f 0b 90 31 db eb d5 9c 58 0f 1f 40 00 f6 c4 02 0f 84 46 ff ff ff 90 <0f> 0b 48 c7 c6 a0 54 d2 87 48 89 df e8 a9 e9 ff ff 90 0f 0b be 04 >>>>>> >>>>>> If I read this BUG correctly, it is: >>>>>> >>>>>> VM_BUG_ON(!in_atomic() && !irqs_disabled()); >>>>>> >>>>> >>>>> Yes, that seems to be the one. >>>>> >>>>>> try_grab_folio() actually assumes it is in an atomic context (irq >>>>>> disabled or preempt disabled) for this call path. This is achieved by >>>>>> disabling irq in gup fast or calling it in rcu critical section in >>>>>> page cache lookup path >>>>> >>>>> try_grab_folio()->try_get_folio()->folio_ref_try_add_rcu() >>>>> >>>>> Is called (mm-unstable) from: >>>>> >>>>> (1) gup_fast function, here IRQs are disable >>>>> (2) gup_hugepte(), possibly problematic >>>>> (3) memfd_pin_folios(), possibly problematic >>>>> (4) __get_user_pages(), likely problematic >>>>> >>>>> (1) should be fine. >>>>> >>>>> (2) is possibly problematic on the !fast path. If so, due to commit >>>>> a12083d721d7 ("mm/gup: handle hugepd for follow_page()") ? CCing Peter. >>>>> >>>>> (3) is possibly wrong. CCing Vivek. >>>>> >>>>> (4) is what we hit here >>>>> >>>>>> >>>>>> And try_grab_folio() is used when the folio is a large folio. The >>>>> >>>>> >>>>> We come via process_vm_rw()->pin_user_pages_remote()->__get_user_pages()->try_grab_folio() >>>>> >>>>> That code was added in >>>>> >>>>> commit 57edfcfd3419b4799353d8cbd6ce49da075cfdbd >>>>> Author: Peter Xu >>>>> Date: Wed Jun 28 17:53:07 2023 -0400 >>>>> >>>>> mm/gup: accelerate thp gup even for "pages != NULL" >>>>> >>>>> The acceleration of THP was done with ctx.page_mask, however it'll be >>>>> ignored if **pages is non-NULL. >>>>> >>>>> >>>>> Likely the try_grab_folio() in __get_user_pages() is wrong? >>>>> >>>>> As documented, we already hold a refcount. Likely we should better do a >>>>> folio_ref_add() and sanity check the refcount. >>>> >>>> Yes, a plain folio_ref_add() seems ok for these cases. >>>> >>>> In addition, the comment of folio_try_get_rcu() says, which is just a >>>> wrapper of folio_ref_try_add_rcu(): >>>> >>>> You can also use this function if you're holding a lock that prevents >>>> pages being frozen & removed; eg the i_pages lock for the page cache >>>> or the mmap_lock or page table lock for page tables. In this case, it >>>> will always succeed, and you could have used a plain folio_get(), but >>>> it's sometimes more convenient to have a common function called from >>>> both locked and RCU-protected contexts. >>>> >>>> So IIUC we can use the plain folio_get() at least for >>>> process_vm_readv/writev since mmap_lock is held in this path. >>>> >>>>> >>>>> >>>>> In essence, I think: try_grab_folio() should only be called from GUP-fast where >>>>> IRQs are disabled. >>>> >>>> Yes, I agree. Just the fast path should need to call try_grab_folio(). >>> >>> try_grab_folio() also handles FOLL_PIN and FOLL_GET, so we may just >>> keep calling it and add a flag to try_grab_folio, just like: >>> >>> if flag is true >>> folio_ref_add() >>> else >>> try_get_folio() >> >> >> try_grab_page() is what we use on the GUP-slow path. We'd likely want a >> folio variant of that. >> >> We might want to call that gup_try_grab_folio() and rename the other one >> to gup_fast_try_grab_folio(). > > Won't we duplicate the most code with two versions try_grab_folio()? > > I meant something like: > > try_grab_folio(struct page *page, int refs, unsigned int flags, bool fast) > { > if fast > try_get_folio() > else > folio_ref_add() > } > That's insufficient to handle FOLL_PIN. Likely we should do this: diff --git a/mm/gup.c b/mm/gup.c index 231711efa390d..fea93a64bf235 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -203,8 +203,8 @@ static void gup_put_folio(struct folio *folio, int refs, unsigned int flags) } /** - * try_grab_page() - elevate a page's refcount by a flag-dependent amount - * @page: pointer to page to be grabbed + * try_grab_folio() - elevate a folios's refcount by a flag-dependent amount + * @folio: pointer to folio to be grabbed * @flags: gup flags: these are the FOLL_* flag values. * * This might not do anything at all, depending on the flags argument. @@ -216,16 +216,16 @@ static void gup_put_folio(struct folio *folio, int refs, unsigned int flags) * time. Cases: please see the try_grab_folio() documentation, with * "refs=1". * + * Must not be called from GUP-fast: the folio must not get freed concurrently. + * * Return: 0 for success, or if no action was required (if neither FOLL_PIN * nor FOLL_GET was set, nothing is done). A negative error code for failure: * * -ENOMEM FOLL_GET or FOLL_PIN was set, but the page could not * be grabbed. */ -int __must_check try_grab_page(struct page *page, unsigned int flags) +int __must_check try_grab_page(struct folio *folio, unsigned int flags) { - struct folio *folio = page_folio(page); - if (WARN_ON_ONCE(folio_ref_count(folio) <= 0)) return -ENOMEM; @@ -239,7 +239,7 @@ int __must_check try_grab_page(struct page *page, unsigned int flags) * Don't take a pin on the zero page - it's not going anywhere * and it is used in a *lot* of places. */ - if (is_zero_page(page)) + if (is_zero_folio(folio)) return 0; /* @@ -260,6 +260,11 @@ int __must_check try_grab_page(struct page *page, unsigned int flags) return 0; } +int __must_check try_grab_page(struct page *page, unsigned int flags) +{ + return gup_try_grab_folio(page_folio(page), flags); +} + /** * unpin_user_page() - release a dma-pinned page * @page: pointer to page to be released Then, fix the callers and rename the other one to gup_fast_*. -- Cheers, David / dhildenb