Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1521606pxm; Thu, 24 Feb 2022 05:00:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzttp1PstIJ4KD0HpIu7T1DGAYmAtbLqNN3QXLMBjq5wxEuTBIoQdS4JtsLPzzB8884HBwx X-Received: by 2002:a05:6402:168e:b0:410:d2a4:b0dd with SMTP id a14-20020a056402168e00b00410d2a4b0ddmr2149310edv.403.1645707611308; Thu, 24 Feb 2022 05:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645707611; cv=none; d=google.com; s=arc-20160816; b=MGNTACBjdoMwuNTeKLhbiBGoXguICNafSqqAZZgSxsOrcPkHjAkgUGvvxW/oWBij9/ fYhoWw16aOGajUmuHOlARt+1tFmia2ywy5AMY4UkdTOn4HZTjah2pI7c35LsuKYHy/2U 4stnfU41Eab6IJsPZTKcGeknz5/2G3IpyVHaqXGr8Su2IKMq+l7dQGlqjtT4NC53sJ/X S+Apl0xT4cW4hFsrawuFhdZ0Dn2eiZKQVcsGXqo9RNxXMfl+6lQJrEpN2aI9QXayR/L7 sB4KcrQhJQvBAguFpHrswPJWhxoEg4Pw5h5dUIj36ta1cbbI2QUfmvjkbiLe5/tDdDwh 2wfg== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=NsEziSD8zXGAxjibXFGFRrDDNKL9BST7ZKyzNe6aCCc=; b=uwO6kmjF5Tn8XR9Iep9ouO7mVxT+u/aMUhA1CaN/ETzIZytZN3qAL+UWfRVRnk4inC l4qJ4zaW8cj9yCeV7H1uX0wJ79H3OCyyP5uwUvJlO8hBytoh8WLg+NEyUUYPA2QMbA0m n+XxxRmZ7ZmIFoqS8CHsIxSQ0RrXaARq1cxCOmyNOQErI2ggkh7I7mDBHuZTQGMlFRWa 64FQFKFtJHCNOvPFOoL9xzt61NNIav0UZNUaS8z3c3qzQfNjGNhIJxGv1Cn92hkmLlpy 9r/l6u7ji2rEmS4/n9a2+1+iQzsdkvDo9nFFxzfBFF4GjyX9PH0Wt5u4dVRikAbc6NYA +1fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linux-ipv6.be header.s=502B7754-045F-11E5-BBC5-64595FD46BE8 header.b=cjdelavZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux-ipv6.be Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg33si1786160ejc.669.2022.02.24.04.59.46; Thu, 24 Feb 2022 05:00:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@linux-ipv6.be header.s=502B7754-045F-11E5-BBC5-64595FD46BE8 header.b=cjdelavZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux-ipv6.be Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233254AbiBXKJx (ORCPT + 99 others); Thu, 24 Feb 2022 05:09:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233227AbiBXKJk (ORCPT ); Thu, 24 Feb 2022 05:09:40 -0500 Received: from mail.tintel.eu (mail.tintel.eu [51.83.127.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 223D128AD96; Thu, 24 Feb 2022 02:09:05 -0800 (PST) Received: from localhost (localhost [IPv6:::1]) by mail.tintel.eu (Postfix) with ESMTP id 50C8C434FC4A; Thu, 24 Feb 2022 11:09:02 +0100 (CET) Received: from mail.tintel.eu ([IPv6:::1]) by localhost (mail.tintel.eu [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id SFVhmd4-Hbc4; Thu, 24 Feb 2022 11:09:01 +0100 (CET) Received: from localhost (localhost [IPv6:::1]) by mail.tintel.eu (Postfix) with ESMTP id BBDAB434FC4B; Thu, 24 Feb 2022 11:09:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.tintel.eu BBDAB434FC4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-ipv6.be; s=502B7754-045F-11E5-BBC5-64595FD46BE8; t=1645697341; bh=NsEziSD8zXGAxjibXFGFRrDDNKL9BST7ZKyzNe6aCCc=; h=Message-ID:Date:MIME-Version:To:From; b=cjdelavZb9bpnlZ24Xu1lGiiftDZaQ9y9quF0qr572LG3GfZefKKt9dUqmP7bjiLj R1a8lWip6pBHta8VooDEz3xgPmIt8MdklEls7mtZKSqClTrUKqLM5TJBk0v+8Siyyx keJo3orc3JNB7CeA95rH4x8IBQDcFtW6jFtaYZlc= X-Virus-Scanned: amavisd-new at mail.tintel.eu Received: from mail.tintel.eu ([IPv6:::1]) by localhost (mail.tintel.eu [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id 0BgzWEgqgmxJ; Thu, 24 Feb 2022 11:09:01 +0100 (CET) Received: from [IPV6:2001:67c:21bc:20::10] (unknown [IPv6:2001:67c:21bc:20::10]) (Authenticated sender: stijn@tintel.eu) by mail.tintel.eu (Postfix) with ESMTPSA id E115A434FC4A; Thu, 24 Feb 2022 11:09:00 +0100 (CET) Message-ID: Date: Thu, 24 Feb 2022 12:08:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] libbpf: fix BPF_MAP_TYPE_PERF_EVENT_ARRAY auto-pinning Content-Language: en-GB To: Andrii Nakryiko , Song Liu Cc: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , Networking , bpf , open list , KP Singh , John Fastabend , Yonghong Song , Song Liu , Martin KaFai Lau , Andrii Nakryiko , Daniel Borkmann , Alexei Starovoitov References: <20220222204236.2192513-1-stijn@linux-ipv6.be> From: Stijn Tintel In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/02/2022 01:15, Andrii Nakryiko wrote: > On Tue, Feb 22, 2022 at 6:37 PM Song Liu wrote: >> On Tue, Feb 22, 2022 at 12:51 PM Stijn Tintel wrote: >>> When a BPF map of type BPF_MAP_TYPE_PERF_EVENT_ARRAY doesn't have the >>> max_entries parameter set, this parameter will be set to the number of >>> possible CPUs. Due to this, the map_is_reuse_compat function will return >>> false, causing the following error when trying to reuse the map: >>> >>> libbpf: couldn't reuse pinned map at '/sys/fs/bpf/m_logging': parameter mismatch >>> >>> Fix this by checking against the number of possible CPUs if the >>> max_entries parameter is not set in the map definition. >>> >>> Fixes: 57a00f41644f ("libbpf: Add auto-pinning of maps when loading BPF objects") >>> Signed-off-by: Stijn Tintel >> Acked-by: Song Liu >> >> I think the following fix would be more future proof, but the patch >> as-is is better for >> stable backport? How about we add a follow up patch on top of current >> patch to fix >> def->max_entries once for all? > Keeping special logic for PERF_EVENT_ARRAY in one place is > preferrable. With this, the changes in map_is_reuse_compat() shouldn't > be necessary at all. Stijn, can you please send v2 with Song's > proposed changes? > Will do! Thanks, Stijn