Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1997624lqa; Tue, 30 Apr 2024 05:53:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXOgIDCvv013NGK4N8m9Ors8MUibQrHml76O/zAozhglUnGwrezelMFS2KCj39AzaTW/63t2CiSqpqVGNf0LQh/wAkL0gLZyeW7dyKEg== X-Google-Smtp-Source: AGHT+IE+WnF34KjqrK6dcntGAZJ0FclgmuscAVqe8Wybvl6hNUxXuDTYqPbz5qo8X9UWBfwStB4Z X-Received: by 2002:ae9:e60c:0:b0:790:f6fb:8762 with SMTP id z12-20020ae9e60c000000b00790f6fb8762mr5564072qkf.76.1714481607144; Tue, 30 Apr 2024 05:53:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714481607; cv=pass; d=google.com; s=arc-20160816; b=GhfF2gB4x+7MW1/9/ipo3aKzeBlNPRqpmPDxrSD8Dd2O7mOfhmqKzfIC+MztABZwCK 7zrphKIgKOFjzHLB/Ad2ORrBQF6dPaQ4nV3XQdX+hIbPl8BXgayPC5tTul+pIel5Y/Ru Y27rGKi3ywVv655oN/iaxHfQB9Pc3IoyIT6nUpjfYA60oDjtWa3uQoooM1p7vXpvGZGb +SX1bYhgymo15oBnaBJs0ODfNaVZmXhupsUHL3s+JwBw34wHKNQD7DJ84WQgK33sw9+V p0yschK7yiWEawz2xDZU89agS4tgYfFJUl6++HJ04V5qRh4Jt6pSVSSQEqM7PAsx7gYR 0eJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=oWqL3ZY85KNjhD8aSZZTQArTMiUJ1o11X6J2QIlGdww=; fh=AHEuUxvO//7QmuHT0Vh/UzsPIUJoMDtqK7PNUFjhweo=; b=xF/fP7DS5k1cFS197dyCyXW+f8NoTApNXYMMb43dP+f/47MxKWY4inFZ9PZyzNIhJ1 cMCsI9DuEu4LXWDXm0cA8UOH5t1ZYvuktpXn0B/tyfx1fB26S6EYgXLMT837ToCP8L0j gihUkppAr93uvCyad3EAEnnL2gFnoF8NSMoqTCd6P9+D6m4v6BmiI5e98vA9lmZ0Ghsh HDnF8D8hU9cTARAhHO0/4WYeQ0av9nPmqZIt+5vy1jRRt3Ifcmt53C4COXOpH+xVgSu7 VQO3SYikrDI6Rkzjo3c/rJNHM6degXQRX3Q618Nai7Jyrdc3jN7Wz4BfUuMApVD3jhIR OU7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MxgB5xaA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-163937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h8-20020ae9ec08000000b007907befbb45si18569014qkg.37.2024.04.30.05.53.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 05:53:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MxgB5xaA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-163937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D8F6F1C2266C for ; Tue, 30 Apr 2024 12:53:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72BBA171666; Tue, 30 Apr 2024 12:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MxgB5xaA" Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1436417109A; Tue, 30 Apr 2024 12:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.67 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714481595; cv=none; b=WZ1Yqrr2tl9NAyxZwcOkvY5ZVJpG2OfFP8Gr2KOqxr3noPctJTjcTLjZ0dT6/6kMdePtnWB+xN40Fnt6jqQmbZUU2VJpE9tHrdzJlfioJ3O4ZxMw/6crbt4s89EA+bVahdnLLb81glFRFOajEEylsjT1xd6M0NlAcQb+K7MVcqQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714481595; c=relaxed/simple; bh=oWqL3ZY85KNjhD8aSZZTQArTMiUJ1o11X6J2QIlGdww=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WxaIvuU3fnlHOoBufTPJdDAXWd8D/XWgempR/VxL1kZ2T61k6mfNjj6j250Gc5YDW1at0ZRy1mQojKUTH4kdb9rIhHuZMIJm2hTuh84kaf+mPb+DaLL0adBF7iRslYP6lMqxF6iz8b9BCVCHoUYKRAja5hRsUOSarfymaGI+89w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MxgB5xaA; arc=none smtp.client-ip=209.85.167.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f67.google.com with SMTP id 2adb3069b0e04-518a56cdc03so6347550e87.1; Tue, 30 Apr 2024 05:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714481592; x=1715086392; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=oWqL3ZY85KNjhD8aSZZTQArTMiUJ1o11X6J2QIlGdww=; b=MxgB5xaARnx7GEi6IaJBRF7aGUdBMLLCYoBLr1l0M6bL6tk6IVktY4wFGdaL0glY/4 hZWn6s107pEqWiLzPIGErMmeSTxqhcZUGLsjvGxlu4RbfUN/URLu3u5alGYMBfeOANKc FDtrqUBuyl7WOaM1OjkDQp8IS+iUap+XLDJD1XOQM3xfQuhF/JhoVzwp8QmSYKCtGJIG sWrWdCij6DMBVhazmM6GLlfjfY5kPN/pBGEiaAZ76Jso8vt223Q4WCKpEkzuR6UG0Gmx FXbDkV2EmNa94rqul7/NMXoWhVKBMUYeaZuYjNwQdWmlX/Y5ME1M2l3DuojNSR8P++0V c0jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714481592; x=1715086392; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oWqL3ZY85KNjhD8aSZZTQArTMiUJ1o11X6J2QIlGdww=; b=oP5A51U6C++eDQ+DI8BgPyPY1Evw6dIywGBxJ6F3LBIDNrBEI6KgD/QlqM7XHUGwAM WTETcZBo0g6HxpT/Vy/8gH7doyPEAtvb3hoXybauFaO4c+J/yR4gNqvpKQZj3kwra+/h gWwQQ9NLwQT7BtC4B6WBWDfF6Wk8lizP40r6VcmWCLClRtzBJNrpgw+8XMo/4u/BtJjs 9vdfGOqxjpxAVwL0zNxdzi9yzdorU8LzMtkhC4re+s4KqYF5vCJruNTe4gHT4q5JQAtS EvFwmjrD2zdIhVH6BZL7WfoX+WxsahorT+dAju4d5UOfvwtRT9yqhZ0qxlaiJraOIYvM XUrg== X-Forwarded-Encrypted: i=1; AJvYcCUtfAk5OUKY/KSy6CIOySOeVwAOUlA0Zv6lipO038PG+h2CHS+YSGFuqbEa2ikDjAyPNZ/gdVXSRf2CZaS72DjOz871qdm1cpuDiRW6Sy2DtjTE5eQ5FN3ubkU7MsOTSlwH+jk3TBB3RVUlOHyhtGGjWIcpxPasLqNH+C/RFbkA0ldX X-Gm-Message-State: AOJu0YyuHjfRwv5ENj+oZkiYvxj4yWjlle4p+iqyPFruNK2mdsNR0bSH sCa6QPKM99hq1tEJntQzhhGxBaI1/Zbkkc+/eMlko+nAEvuNfQjILhfhPHOAeKWW0wmcqG4JSB8 V66ub3j3e6iyIDVhJjv2iYEfOzwM= X-Received: by 2002:a19:9157:0:b0:516:d33a:7571 with SMTP id y23-20020a199157000000b00516d33a7571mr9167898lfj.8.1714481591989; Tue, 30 Apr 2024 05:53:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240430-bpf-next-v3-0-27afe7f3b17c@kernel.org> <20240430-bpf-next-v3-2-27afe7f3b17c@kernel.org> In-Reply-To: <20240430-bpf-next-v3-2-27afe7f3b17c@kernel.org> From: Kumar Kartikeya Dwivedi Date: Tue, 30 Apr 2024 14:52:35 +0200 Message-ID: Subject: Re: [PATCH bpf-next v3 2/3] bpf: do not walk twice the hash map on free To: Benjamin Tissoires Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Tue, 30 Apr 2024 at 12:44, Benjamin Tissoires wrote: > > If someone stores both a timer and a workqueue in a hash map, on free, we > would walk it twice. > Add a check in htab_free_malloced_timers_or_wq and free the timers > and workqueues if they are present. > > Fixes: 246331e3f1ea ("bpf: allow struct bpf_wq to be embedded in arraymaps and hashmaps") > Signed-off-by: Benjamin Tissoires > > --- I had forgotten how the extra_elems logic is working, turns out everything is in the preallocated elems array and per-cpu extra_elems stores the *pointer* to them for recycling without hitting the pcpu allocator, so should be fine (just in case this confuses anyone else). > > changes in v3: > - fix unloading of bpf_wq, again > > changes in v2: > - fix wq being not freed (and static call not used) > --- Acked-by: Kumar Kartikeya Dwivedi