Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4360438pxu; Wed, 9 Dec 2020 15:22:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJ+R5RpuBrxEP8x2kyvDrhZ8+N684NTF2LRUucLPIxDeFYGgZJN09om5mFTO6DVbkNG18y X-Received: by 2002:a17:906:369b:: with SMTP id a27mr4148514ejc.183.1607556138440; Wed, 09 Dec 2020 15:22:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607556138; cv=none; d=google.com; s=arc-20160816; b=zG5hpGrXhord87BahnOfPCuODLwyhEk/uDSqEgB7Cn8mhfPqsFOYXLv/Wrm7gtlWAm f8lq5fhW5u1kiK1LFhw6E3LQqeR7wmgUQNWaUlryACEA0+8zynovQQDGWL5f4KSpZU+r aPV9B0MmCY/lUksTxDbN1GzrhiFnud332w0tsyvCLJHDbQ75DDhNaJVFE2nz9lmSff96 bRR0q7dIxlL+DJQfBUPmaNJrwl+lIsQ5Xh+H3nRHq38VBcXs/xuXhs52wBnlW7BtRHxi 0zBIoMd57zCgdU1nxCzbM8UaiuqUl4rufTOm3V9MA15HNA8CKirB7QWy3Rhwv2VD20ky X90Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=G4gieWn3NOA1JhbTP5C00RsfdCAbf1Ni5bGd/KXjYBU=; b=WYjjYW2iEZDr43vL6QxkSMCertdSR3FgiOblDLCiDD3dFYm6HVMzis+RsctEaPs9so SGPJfYI+39xyVjxnoUZqdkjBfKaUIRTCSabBAoVGt42XM4oq4QPBX+dhc7dPK+BQdsau x+UTu2KiFlmU5WPx2O/XkcJ7N5JiZ+KkDo7swDWFlgpOQyehsF3tx1/Wwv4gDnbtIiyA vWIJRnyKp0WZ2YOcJacuB4kOKCQxjKkT081mcZp84fszvR27qQYB3HvzGmOQAqFk37W+ uW6Uq88Dd94kKRIwhgzOu4tDcycKh4T9nBsQGwvSnY2IpwYhO0ktjte9P/rtEc9RonEu fy4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=yZ7Fs9KE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df20si1639299edb.366.2020.12.09.15.21.54; Wed, 09 Dec 2020 15:22:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=yZ7Fs9KE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733194AbgLIOrY (ORCPT + 99 others); Wed, 9 Dec 2020 09:47:24 -0500 Received: from mx3.wp.pl ([212.77.101.9]:57441 "EHLO mx3.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733175AbgLIOrY (ORCPT ); Wed, 9 Dec 2020 09:47:24 -0500 Received: (wp-smtpd smtp.wp.pl 13428 invoked from network); 9 Dec 2020 15:46:29 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1607525189; bh=G4gieWn3NOA1JhbTP5C00RsfdCAbf1Ni5bGd/KXjYBU=; h=From:To:Cc:Subject; b=yZ7Fs9KEiQTtlPKWuv8naJ3A1vIE3Ii3CET5v81g1ueRDyPP/CY0kvhQ+qtkXUwC/ 0wjgVdQnppcWJaaae38+Xr7Cd6qSpjSbcC7A32n/Na7+eLoVcwp692L2HqcxPgQ323 8jiNmHuYBH4+IfyRPYZ02RgQJjNCFZaxSAC81wtw= Received: from ip4-46-39-164-203.cust.nbox.cz (HELO localhost) (stf_xl@wp.pl@[46.39.164.203]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 9 Dec 2020 15:46:29 +0100 Date: Wed, 9 Dec 2020 15:46:28 +0100 From: Stanislaw Gruszka To: Alexei Starovoitov Cc: Michal Kubecek , Justin Forbes , bpf , Alex Shi , Andrew Morton , Souptick Joarder , Linux-MM , LKML , Alexei Starovoitov , Daniel Borkmann , Josef Bacik Subject: Re: [PATCH] mm/filemap: add static for function __add_to_page_cache_locked Message-ID: <20201209144628.GA3474@wp.pl> References: <1604661895-5495-1-git-send-email-alex.shi@linux.alibaba.com> <20201110115037.f6a53faec8d65782ab65d8b4@linux-foundation.org> <20201207081556.pwxmhgdxayzbofpi@lion.mk-sys.cz> <20201207225351.2liywqaxxtuezzw3@lion.mk-sys.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-WP-MailID: 9e0b255261161f2ea3e8b8d7c7c110d4 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000000 [oZPU] Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 07, 2020 at 05:12:52PM -0800, Alexei Starovoitov wrote: > > > > > > > >>> -noinline int __add_to_page_cache_locked(struct page *page, > > > > > > > >>> +static noinline int __add_to_page_cache_locked(struct page *page, > > > > > > > >>> struct address_space *mapping, > > > > > > > >>> pgoff_t offset, gfp_t gfp, > > > > > > > >>> void **shadowp) > > > > > > > > > > > > > > > > It's unclear to me whether BTF_ID() requires that the target symbol be > > > > > > > > non-static. It doesn't actually reference the symbol: > > > > > > > > > > > > > > > > #define BTF_ID(prefix, name) \ > > > > > > > > __BTF_ID(__ID(__BTF_ID__##prefix##__##name##__)) [snip] > > > __add_to_page_cache_locked") made the function static which breaks the > > > build in btfids phase - but it seems to happen only on some > > > architectures. In our case, ppc64, ppc64le and riscv64 are broken, > > > x86_64, i586 and s390x succeed. (I made a mistake above, aarch64 did not > > > fail - but only because it was not built at all.) > > > > > > The thread starts with > > > http://lkml.kernel.org/r/1604661895-5495-1-git-send-email-alex.shi@linux.alibaba.com I have 5.10-rc7 build failure because of this on x86_64: BTFIDS vmlinux FAILED unresolved symbol __add_to_page_cache_locked make: *** [Makefile:1170: vmlinux] Error 255 > > Got it. So the above commit is wrong. > > The addition of "static" is incorrect here. > > Regardless of btf_id generation. > > "static noinline" means that the error injection in that spot is unreliable. > > Even when bpf is completely compiled out of the kernel. > > I finally realized that the addition of 'static' was pushed into Linus's tree :( > Please revert commit 3351b16af494 ("mm/filemap: add static for > function __add_to_page_cache_locked") At this point of release cycle we should probably go with revert, but I think the main problem is that BPF and ERROR_INJECTION use function that is not intended to be used externally. For external users add_to_page_cache_lru() and add_to_page_cache_locked() are exported and I think those should be used (see the patch below). Stanislaw diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 1388bf733071..dd6357802504 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -11487,7 +11487,8 @@ BTF_SET_START(btf_non_sleepable_error_inject) /* Three functions below can be called from sleepable and non-sleepable context. * Assume non-sleepable from bpf safety point of view. */ -BTF_ID(func, __add_to_page_cache_locked) +BTF_ID(func, add_to_page_cache_locked) +BTF_ID(func, add_to_page_cache_lru) BTF_ID(func, should_fail_alloc_page) BTF_ID(func, should_failslab) BTF_SET_END(btf_non_sleepable_error_inject) diff --git a/mm/filemap.c b/mm/filemap.c index 331f4261d723..168deec64a10 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -827,10 +827,10 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask) } EXPORT_SYMBOL_GPL(replace_page_cache_page); -static noinline int __add_to_page_cache_locked(struct page *page, - struct address_space *mapping, - pgoff_t offset, gfp_t gfp, - void **shadowp) +static int __add_to_page_cache_locked(struct page *page, + struct address_space *mapping, + pgoff_t offset, gfp_t gfp, + void **shadowp) { XA_STATE(xas, &mapping->i_pages, offset); int huge = PageHuge(page); @@ -907,7 +907,6 @@ static noinline int __add_to_page_cache_locked(struct page *page, put_page(page); return error; } -ALLOW_ERROR_INJECTION(__add_to_page_cache_locked, ERRNO); /** * add_to_page_cache_locked - add a locked page to the pagecache @@ -928,6 +927,7 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping, gfp_mask, NULL); } EXPORT_SYMBOL(add_to_page_cache_locked); +ALLOW_ERROR_INJECTION(add_to_page_cache_locked, ERRNO); int add_to_page_cache_lru(struct page *page, struct address_space *mapping, pgoff_t offset, gfp_t gfp_mask) @@ -957,6 +957,7 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping, return ret; } EXPORT_SYMBOL_GPL(add_to_page_cache_lru); +ALLOW_ERROR_INJECTION(add_to_page_cache_lru, ERRNO); #ifdef CONFIG_NUMA struct page *__page_cache_alloc(gfp_t gfp)