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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AB75C47077 for ; Sun, 14 Jan 2024 20:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LNyhi8it9X+UfKgiykYTJ2rDnL9FXaAQz75OqnbJfHs=; b=dEwOScihNQsoDe l2q13V+jZ8oMxHvEdIGT2HLSJX6Zcr0lzxhkYqW1dyvjjcrd8DOG8g1TpiRVNbv61TEvBT+P4Wy/T 4m6GnCn+EkYoqCTf+ChmUZ+aW7ZJ8xAH011JiiCzXbySwDJbBLRKGvNwbPnnrRNKzBK+ZLhpPC4fb Dci/6bYlJ56vYaS++FyQhZib036T1MVbbsg2tMPSCMiCvaoKk3M/EQXdrf87/1XfLa+c5eKLQdcLf 1+Cbwy+NlQJM6N30F3w3YAPJKUdu2mS6F5KFWoKCvKgbmE1qBxgnlUX8XJqmw44VesaJ13QloqIYz BPcC3EVK53SXC+fS4Aog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rP7Vy-007KAk-2U; Sun, 14 Jan 2024 20:55:30 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rP7Vr-007K8m-0u for linux-arm-kernel@lists.infradead.org; Sun, 14 Jan 2024 20:55:29 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-50e835800adso8700961e87.0 for ; Sun, 14 Jan 2024 12:55:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705265718; x=1705870518; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=OjdwhhShuxIM1mqbVlzcS4sQ3O1tzPChgxO0uqhf+Bw=; b=eHxQZO6Oa38W/95ys6NxYPrcSxv7QCT/0hKTQWTRZyDpmeYzWGZtieIBfsWzn8+GyZ 2cKKnlgZAtKIADeOjpHbtCsBFpDm2DWUUHCPs0CJw4oa8DQ556/TDoaxErjRNXf0cEjv 1jQ9OWNab3yViNh8V6cu0ZUjf3DwYMSy2vK6oN1dn+OjuykcQP0Yag2S/p+TXFGeQ6km vfgvH0Z7QTsIVnOSyzS4rMaBPOXiCbQrzgUpw3i2St25DxSDQWSIjF57+MyEayc+vUre y0bnerndAk+qfoLtqX6LpUWeIcKLD0ZOOMTTLlFPVvGIIUmYy2u5D2cMkLDnrrZ+96ml nSJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705265718; x=1705870518; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OjdwhhShuxIM1mqbVlzcS4sQ3O1tzPChgxO0uqhf+Bw=; b=IGZKYgL7ScFXwudOexkKnJfwQiU3dw0Wwwz5ilwfOMJshWy9K57YsA9OQf/1bwpj2E TwAJRWYi9l9TGirU1c0uLkbXszXf9sdWwTctFdKImHZpjD4l0v3HPSzxCvGd77rrFCPd kYTf6FDoFUblxUimot4yUrwEAljIdRQ68kkzFbeoemfqHJgJR/ymcvSgcoba99XBT646 APhRDLvQmDJwPpVbRG8a2AIzwtUJfqAbjq/pk/wHlNVM5FPsfE1yZKVPqa8EOOU1/aei 6Twj6/7s05RiI7EItE/HoMsu1MXvhGqLL7/NyWOSItABh0QjdBEFeCb9g/dqAQQJwupx fA8g== X-Gm-Message-State: AOJu0YxMVHpaVRFcd5WxYLP1OlD1XeCYDVxByCGH9rSTxhw3sy2tN2YP KGciX9fZA3hxcVTyrjgcouA= X-Google-Smtp-Source: AGHT+IFSg7sPPT5du0kGDtu5w62WANdm97nr297wUbBkWA5r0LG3EslmUwuam5znWD2kqpR+oYiCFw== X-Received: by 2002:a05:6512:39d5:b0:50e:902d:b44 with SMTP id k21-20020a05651239d500b0050e902d0b44mr1718048lfu.8.1705265718182; Sun, 14 Jan 2024 12:55:18 -0800 (PST) Received: from krava ([83.240.63.77]) by smtp.gmail.com with ESMTPSA id vh1-20020a170907d38100b00a2daf80d017sm823904ejc.6.2024.01.14.12.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 12:55:17 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Sun, 14 Jan 2024 21:55:15 +0100 To: David Hildenbrand Cc: Jiri Olsa , Ryan Roberts , Andrew Morton , Matthew Wilcox , Yin Fengwei , Yu Zhao , Catalin Marinas , Anshuman Khandual , Yang Shi , "Huang, Ying" , Zi Yan , Luis Chamberlain , Itaru Kitayama , "Kirill A. Shutemov" , John Hubbard , David Rientjes , Vlastimil Babka , Hugh Dickins , Kefeng Wang , Barry Song <21cnbao@gmail.com>, Alistair Popple , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Barry Song Subject: Re: [PATCH v9 02/10] mm: Non-pmd-mappable, large folios for folio_add_new_anon_rmap() Message-ID: References: <20231207161211.2374093-1-ryan.roberts@arm.com> <20231207161211.2374093-3-ryan.roberts@arm.com> <41dc7dff-1ea8-4894-a487-88d46ec2b2d8@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <41dc7dff-1ea8-4894-a487-88d46ec2b2d8@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240114_125523_342894_7D044065 X-CRM114-Status: GOOD ( 41.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Jan 14, 2024 at 06:33:56PM +0100, David Hildenbrand wrote: > On 13.01.24 23:42, Jiri Olsa wrote: > > On Thu, Dec 07, 2023 at 04:12:03PM +0000, Ryan Roberts wrote: > > > In preparation for supporting anonymous multi-size THP, improve > > > folio_add_new_anon_rmap() to allow a non-pmd-mappable, large folio to be > > > passed to it. In this case, all contained pages are accounted using the > > > order-0 folio (or base page) scheme. > > > > > > Reviewed-by: Yu Zhao > > > Reviewed-by: Yin Fengwei > > > Reviewed-by: David Hildenbrand > > > Reviewed-by: Barry Song > > > Tested-by: Kefeng Wang > > > Tested-by: John Hubbard > > > Signed-off-by: Ryan Roberts > > > --- > > > mm/rmap.c | 28 ++++++++++++++++++++-------- > > > 1 file changed, 20 insertions(+), 8 deletions(-) > > > > > > diff --git a/mm/rmap.c b/mm/rmap.c > > > index 2a1e45e6419f..846fc79f3ca9 100644 > > > --- a/mm/rmap.c > > > +++ b/mm/rmap.c > > > @@ -1335,32 +1335,44 @@ void page_add_anon_rmap(struct page *page, struct vm_area_struct *vma, > > > * This means the inc-and-test can be bypassed. > > > * The folio does not have to be locked. > > > * > > > - * If the folio is large, it is accounted as a THP. As the folio > > > + * If the folio is pmd-mappable, it is accounted as a THP. As the folio > > > * is new, it's assumed to be mapped exclusively by a single process. > > > */ > > > void folio_add_new_anon_rmap(struct folio *folio, struct vm_area_struct *vma, > > > unsigned long address) > > > { > > > - int nr; > > > + int nr = folio_nr_pages(folio); > > > - VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma); > > > + VM_BUG_ON_VMA(address < vma->vm_start || > > > + address + (nr << PAGE_SHIFT) > vma->vm_end, vma); > > > > hi, > > I'm hitting this bug (console output below) with adding uprobe > > on simple program like: > > > > $ cat up.c > > int main(void) > > { > > return 0; > > } > > > > # bpftrace -e 'uprobe:/home/jolsa/up:_start {}' > > > > $ ./up > > > > it's on top of current linus tree master: > > 052d534373b7 Merge tag 'exfat-for-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat > > > > before this patch it seems to work, I can send my .config if needed > > bpf only inserts a small folio, so no magic there. > > It was: > VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma); > And now it is > VM_BUG_ON_VMA(address < vma->vm_start || address + (nr << PAGE_SHIFT) > vma->vm_end, vma); > > I think this change is sane. As long as the address is aligned to full pages > (which it better should be) > > Staring at uprobe_write_opcode, likely vaddr isn't aligned ... > > Likely (hopefully) that is not an issue for __folio_set_anon(), because linear_page_index() > will mask these bits off. > > > Would the following change fix it for you? great, that fixes it for me, you can add my Tested-by: Jiri Olsa thanks, jirka > > From c640a8363e47bc96965a35115a040b5f876c4320 Mon Sep 17 00:00:00 2001 > From: David Hildenbrand > Date: Sun, 14 Jan 2024 18:32:57 +0100 > Subject: [PATCH] tmp > > Signed-off-by: David Hildenbrand > --- > kernel/events/uprobes.c | 2 +- > mm/rmap.c | 1 + > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c > index 485bb0389b488..929e98c629652 100644 > --- a/kernel/events/uprobes.c > +++ b/kernel/events/uprobes.c > @@ -537,7 +537,7 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, > } > } > - ret = __replace_page(vma, vaddr, old_page, new_page); > + ret = __replace_page(vma, vaddr & PAGE_MASK, old_page, new_page); > if (new_page) > put_page(new_page); > put_old: > diff --git a/mm/rmap.c b/mm/rmap.c > index f5d43edad529a..a903db4df6b97 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1408,6 +1408,7 @@ void folio_add_new_anon_rmap(struct folio *folio, struct vm_area_struct *vma, > { > int nr = folio_nr_pages(folio); > + VM_WARN_ON_FOLIO(!IS_ALIGNED(address, PAGE_SIZE), folio); > VM_WARN_ON_FOLIO(folio_test_hugetlb(folio), folio); > VM_BUG_ON_VMA(address < vma->vm_start || > address + (nr << PAGE_SHIFT) > vma->vm_end, vma); > -- > 2.43.0 > > > > -- > Cheers, > > David / dhildenb > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel