Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp557725lqt; Mon, 18 Mar 2024 16:54:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXriHhLw2mWsmeSZZqZmIpRzGuHQ2XoGHgP2JQh3VkSMjUPCH6LEPKf/mJ8cR1XqdVLMTYAQZKN9VhBw5RgKZrLEVEFbKVV74lyij8efg== X-Google-Smtp-Source: AGHT+IEYlZCOfcM4RDfTlMsLROohS0GpMK8lKXy/bhuEGhicLu3LLYH4bCGLHbF8QUH/fk8tQJX7 X-Received: by 2002:a17:906:7b54:b0:a45:373:d0a with SMTP id n20-20020a1709067b5400b00a4503730d0amr9873116ejo.32.1710806095057; Mon, 18 Mar 2024 16:54:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710806095; cv=pass; d=google.com; s=arc-20160816; b=D9bGLoSgXIDMk06etCh88PJTfzskaQYp4XBdcu55FPJbJUveZgHUq22mr3BImt2DTn ol9LI3/yMl5A18X+v66vhHcb3MegI5wXkKL0JFQ/NjgXTw5qiRYFIqU+guT9NTJssoiO iDJVTGADnbdwdwBttySsbwPUMsd/e43cUr0L4H46R697ZlgYxd9wENKKaRhJCCzHVdSR GXHkvrlzWOW4OhD+6WPnPkARLgiDjaPzyHQ4w6Vw8Zhc/nlStLmEBKzuePIfKdveB+ec EU1+/iC1UO2klDbd7JoeYbg5cBNXxZ5skJKA++5XAFM2MeyFboPPb5cAYvnh6mcvt8oR yVGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=xsqudSCPxYDZb7vIDJzkGeBhlTUqtvhnvvGW1FIJAQA=; fh=MH5hINlPo2h9Hp9QbbHjmZMG+HWAt6Wg7KlsLdtbi14=; b=OrU+cEhGHvQDgYw/Xy2Zq6aGZ5oUQ1G93sT1WAlgKxgdveN9Ugw4G9NYItIRiOiF8S 3QQEJ7Qz50N31IUCPJ4v2GqUt6+gxEh2ky3Vg2j81MtzSi/Oe/B3EtBGA0JeYrAoAana ux7G093RiLZ8K774ClZBJsmDMpcFBqGZoddGx+F1GaJYJWJHMPfBHQ6+9xeICPindKv2 ylZbK9n5Y8LrfYOtrCZxD8HjasIeK2NRJ1Q2xlC9I6oDXLFkbGATQPU/a2RokhS5Wh8x 1yjSiWBd9kz4ctPfwyNjxROBG17MmShQ1sh1DFcSmk7rVd1mgnm7TmpYBMDiJUqR7wYI gzYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VBoI8BDN; 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-106833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o15-20020a170906288f00b00a461e236482si4702119ejd.631.2024.03.18.16.54.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VBoI8BDN; 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-106833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106833-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9E01A1F236F5 for ; Mon, 18 Mar 2024 23:54:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E5FF5F87E; Mon, 18 Mar 2024 23:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VBoI8BDN" Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 CB1C35F861; Mon, 18 Mar 2024 23:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806082; cv=none; b=cR4x/avIEvb9AbNvRDmD3ev9b3TKY7f3uJwJra7BQmGn4ss7rdy9RbqWASjvItg0RtVaA0afoNXfuD82k7jKskFqCblhVF07todVuBpREL37p2oTHoevrzC8r2/ItyL312f4DUJnXIi//f84sOxGPUC83r2drf52ucQ64+41fGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806082; c=relaxed/simple; bh=2ampYUB3qmvgKnA422RU+89kfH3qiVaLbH2sevIcLo0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=nD+E75GWP1Nq89iwoo9Nx1eOEabqnhK/4dNurydJZ8Yk1XnKjlUpKUPgtHOp3guIhTVZselv9mEOzAGicyEZc306RIT8wpIyKApMsDosEMwvUtvRM9zautHCH1SdiU1K74dqN1JA7VXmB3ABEkN1B8EXhgHjhwSnhe+3nWANW9c= 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=VBoI8BDN; arc=none smtp.client-ip=209.85.208.177 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-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d24a727f78so57987381fa.0; Mon, 18 Mar 2024 16:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710806079; x=1711410879; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to; bh=xsqudSCPxYDZb7vIDJzkGeBhlTUqtvhnvvGW1FIJAQA=; b=VBoI8BDNj/0XcIyEPIW4qBJ6ENa/RDVcGllGjTGtHxnZBA6uusLJHBcd6dkhDYWzjS rP2Hh206SPH3TIFGaC5T3BcwgnfJU+UyH/eS1N8VZJo4VHLUmzheYTU05WZvsCbh93He e7HnLVVILC+//9f8jcXqPAFNaeVPf2MFyLymCeeU/5y2B1ufzPczrYO51tNfxUYn+TWq Ir5V2vxGDsJ1MHf7mpKvqLde4rxFcyBktczsYo5UBM8CF7jYi6Im9bP8M9utTeY5DvqF X+FqHS8d8hjfsZn7M+F3WFu099AexrrNuocvHHSt7pPiJ6JTQbTFzFmLDXMhxTCs1sT2 RrnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710806079; x=1711410879; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xsqudSCPxYDZb7vIDJzkGeBhlTUqtvhnvvGW1FIJAQA=; b=bOzGF33hOPvRwmRfDHrc859qeYZm+9kRDKGBaW2vXeVeO6ZDebfPx3xYPahkF7j1MF o10wETCZTTvU72OCfk1tLO9N2EReWnct3hQyM3LAn900K+PO+zA/NYR/bEgnP++cs50i DahOy4RkDeH0OXzkhEmAbIGoZw6BfzjtKtGXcER+82S7hzKdZaUnOlD52vGRttGZNm/z i7qXKdABvwDIYAIrfT7mi930HRTF2hOOpt/nRgrVndNQMKXSHs1+tSKahLrImVeI4VJT fQm4xIxU+1boh0s5342Fq2KXR8NmGQJN4jT53Zc6VFViLUGIcgtI1G5iu21Tn1tOVXZd QlqA== X-Forwarded-Encrypted: i=1; AJvYcCXw6vcHErWYZyGv+VSEaVbA4iic/cked4YV0pgSGxVukUVTlI2sQr1ILQB8UfhD+WlCZEiQ47ylN3j5eYWJGizvJ14bqEauo7wYYwJ7zZxi41peq2L1rVj8R+f0kxEGNvugG+memmoAOjDVNuVN X-Gm-Message-State: AOJu0Yz/11x03ZQUsknGT1CQ+uQ/GXB87YJKSKXC1Zp1wX8orV09S4N4 bdQdyM8xQeXK2+cah/ZbpvpK/FoPTpdnjQHSvsVtAMcRXFxERu65 X-Received: by 2002:a05:6512:3687:b0:512:f6a0:1311 with SMTP id d7-20020a056512368700b00512f6a01311mr8317091lfs.47.1710806078749; Mon, 18 Mar 2024 16:54:38 -0700 (PDT) Received: from [192.168.6.255] ([5.1.5.0]) by smtp.gmail.com with ESMTPSA id di17-20020a170906731100b00a45aa7cb029sm5340411ejc.36.2024.03.18.16.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 16:54:38 -0700 (PDT) Message-ID: Subject: Re: [PATCH bpf-next v4 4/6] bpf/helpers: mark the callback of bpf_timer_set_sleepable_cb() as sleepable From: Eduard Zingerman To: Benjamin Tissoires , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Date: Tue, 19 Mar 2024 01:54:36 +0200 In-Reply-To: <20240315-hid-bpf-sleepable-v4-4-5658f2540564@kernel.org> References: <20240315-hid-bpf-sleepable-v4-0-5658f2540564@kernel.org> <20240315-hid-bpf-sleepable-v4-4-5658f2540564@kernel.org> Autocrypt: addr=eddyz87@gmail.com; prefer-encrypt=mutual; keydata=mQGNBGKNNQEBDACwcUNXZOGTzn4rr7Sd18SA5Wv0Wna/ONE0ZwZEx+sIjyGrPOIhR14/DsOr3ZJer9UJ/WAJwbxOBj6E5Y2iF7grehljNbLr/jMjzPJ+hJpfOEAb5xjCB8xIqDoric1WRcCaRB+tDSk7jcsIIiMish0diTK3qTdu4MB6i/sh4aeFs2nifkNi3LdBuk8Xnk+RJHRoKFJ+C+EoSmQPuDQIRaF9N2m4yO0eG36N8jLwvUXnZzGvHkphoQ9ztbRJp58oh6xT7uH62m98OHbsVgzYKvHyBu/IU2ku5kVG9pLrFp25xfD4YdlMMkJH6l+jk+cpY0cvMTS1b6/g+1fyPM+uzD8Wy+9LtZ4PHwLZX+t4ONb/48i5AKq/jSsb5HWdciLuKEwlMyFAihZamZpEj+9n91NLPX4n7XeThXHaEvaeVVl4hfW/1Qsao7l1YjU/NCHuLaDeH4U1P59bagjwo9d1n5/PESeuD4QJFNqW+zkmE4tmyTZ6bPV6T5xdDRHeiITGc00AEQEAAbQkRWR1YXJkIFppbmdlcm1hbiA8ZWRkeXo4N0BnbWFpbC5jb20+iQHUBBMBCgA+FiEEx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SIGNNAqK+SiLLXt51G7P30TVavIeB6s2lCt1QKt62ccLqUAEQEAAYkBvAQYAQoAJhYhBMfui64wKUMqp1wmBC4MZXpJYEQJBQJijTUBAhsMBQkDwmcAAAoJEC4MZXpJYEQJkRAMAKNvWVwtXm/WxWoiLnXyF2WGXKoDe5+itTLvBmKcV/b1OKZF1s90V7WfSBz712eFAynEzyeezPbwU8QBiTpZcHXwQni3IYKvsh7s t1iq+gsfnXbPz5AnS598ScZI1oP7OrPSFJkt/z4acEbOQDQs8aUqrd46PV jsdqGvKnXZxzylux29UTNby4jTlz9pNJM+wPrDRmGfchLDUmf6CffaUYCbu4FiId+9+dcTCDvxbABRy1C3OJ8QY7cxfJ+pEZW18fRJ0XCl/fiV/ecAOfB3HsqgTzAn555h0rkFgay0hAvMU/mAW/CFNSIxV397zm749ZNLA0L2dMy1AKuOqH+/B+/ImBfJMDjmdyJQ8WU/OFRuGLdqOd2oZrA1iuPIa+yUYyZkaZfz/emQwpIL1+Q4p1R/OplA4yc301AqruXXUcVDbEB+joHW3hy5FwK5t5OwTKatrSJBkydSF9zdXy98fYzGniRyRA65P0Ix/8J3BYB4edY2/w0Ip/mdYsYQljBY0A== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2024-03-15 at 15:29 +0100, Benjamin Tissoires wrote: [...] > @@ -5279,7 +5281,8 @@ static int map_kptr_match_type(struct bpf_verifier_= env *env, > =20 > static bool in_sleepable(struct bpf_verifier_env *env) > { > - return env->prog->sleepable; > + return env->prog->sleepable || > + (env->cur_state && env->cur_state->in_sleepable); > } I was curious why 'env->cur_state &&' check was needed and found that removing it caused an error in the following fragment: static int do_misc_fixups(struct bpf_verifier_env *env) { ... if (is_storage_get_function(insn->imm)) { if (!in_sleepable(env) || env->insn_aux_data[i + delta].storage_get_func_atomic) insn_buf[0] =3D BPF_MOV64_IMM(BPF_REG_5, (__force __s32)GFP_ATOMIC); else insn_buf[0] =3D BPF_MOV64_IMM(BPF_REG_5, (__force __s32)GFP_KERNEL); ... } ... } When do_misc_fixups() is done env->cur_state is NULL. Current implementation would use GFP_ATOMIC allocation even for sleepable callbacks, where GFP_KERNEL is sufficient. Is this is something we want to address? > =20 > /* The non-sleepable programs and sleepable programs with explicit bpf_r= cu_read_lock()