Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp632671rdb; Thu, 22 Feb 2024 14:40:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXUWlV+4SInzP9MsV13OIcZKLeRfRPYkrBqYvkH07tbe8C767jAe+vlU8Ae9AiofrYrQgsWmNt9fPMpoobsnqmgJA72mldfPr21FhSc+w== X-Google-Smtp-Source: AGHT+IGO5P5yetfqR7x+UMvXAYfZfIwCGJNmM2Jj0l31rFjbSpSrzC0wDL/RdHgBntciOVwGS4/M X-Received: by 2002:a17:906:c309:b0:a3f:176d:23bb with SMTP id s9-20020a170906c30900b00a3f176d23bbmr106167ejz.61.1708641643433; Thu, 22 Feb 2024 14:40:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708641643; cv=pass; d=google.com; s=arc-20160816; b=qwAfte9T479g9TAcVAvrbrt8JO/eDqKpqZieu/YblKDmDVfLWdfhLIB4eVpyqsbRia ERfV6R0eRdZtRvlTX+RxubwzRbHntfrnjmakv0XYo4L46ZPZM97ETQ/eguuNUMBVFJx/ ccf9ozcoERaLz2IpDdKim5cmmsY2MgrkXGS4O6YVs9FFUo23dA6JiFwT61t0h3R99wW8 j6xvMP3UfkMBfkEUuXM63urPl6h2SwOK15Z707Zetf4wdy/V4rMAdIqwvmqH87pKiL7o lduVrC4w8HGsPDWlK5tpnihd+4/ZJ8k2fKvBqx1TdWHAS126JG2AfrgEPqzweHJLJv7x B0aw== 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=rrbPrUW0ZTICdu2T6tV53S8IPihVOgjh3KZxbVHsClY=; fh=TX2OUSPZ1bQYxCaVWzdgIw4RzIDuJj9seyvznqQdd2k=; b=FGAX9GSTXigPgUs9z0EnxU+21cuc/aZF9j7lP+rh+Ruf3NhfjMTgyO1GBQngvUukx6 9C9MDbmEMZIicZrVyG2yiO45Co7UvjxzNzr4ugl8HNG1Uuc9/T63uLSByqajbdWhDMFv SlGKnCwr9WDy48DLeqAfWrOwOwQhFuVBsrs1zmUAU784jeai/7e2275sCzM8rJkHHNAt dogpm3JZymOhQ/ZiEX4XN3+4zgDA0LU5Anq55J9YI1u9xk82D8MGE7kdYr0wFvkSB29u 9K4s8/bCY1Tj2Z4JqCttjYib4sRDQRYrDlDUXI8MmrqIZv5DQl7gQvJXoa/rHMrKveIP A3bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ku1lUnks; 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-77471-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77471-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. [147.75.80.249]) by mx.google.com with ESMTPS id nc17-20020a1709071c1100b00a3f554f9c57si1557836ejc.481.2024.02.22.14.40.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 14:40:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77471-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ku1lUnks; 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-77471-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77471-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 0045E1F249A4 for ; Thu, 22 Feb 2024 22:40:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B6EF18643; Thu, 22 Feb 2024 22:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ku1lUnks" Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 9C1E7DDB0; Thu, 22 Feb 2024 22:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708641629; cv=none; b=ej8DjtFk5LiWmJeT24h2KCH+r0WUGb8nVVneSr0jczLlo30qL1oiXS0U/PnXiGV0pyLkBGZBBgc5XPlYizRdmGqMvznplsfSZCK9QfaHMkPB/fQSE4IIZAocJyYPiH0PPddcQhiwd2Rm23fd8ijFr+6Yihhgh2mRpCLBLgS2AHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708641629; c=relaxed/simple; bh=QU7B0XmAaxdAKxWi2ZnCqyUi/1Q95b2uymSLhj4IYas=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=Wsz9rvL0NY4vG5lwu82CO/iPyCDo3wsmBdNfKiCKsBYzPfPwQ+7cOBeFkXHu5Ooi7QB/46HmmBaWvPE+LDNplVsqjl4JRVzPhAn/fBKe63D+MD6KuNHP/9vwEi9XXAiUQWytfRoTkA8u6UlEcBJIO7JByFLt3rgLChork3LuqkE= 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=Ku1lUnks; arc=none smtp.client-ip=209.85.221.50 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-wr1-f50.google.com with SMTP id ffacd0b85a97d-33d28468666so180179f8f.0; Thu, 22 Feb 2024 14:40:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708641626; x=1709246426; 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=rrbPrUW0ZTICdu2T6tV53S8IPihVOgjh3KZxbVHsClY=; b=Ku1lUnksAnCgco/gNyWmhpqJACD54APc9v83UJ/0F0FNQbciLcMw9GrpDZCWjCBzt4 cba+X1wlm36CIax1upRIP1OWvN9O7JKCSrLRs1u+iGlXw8dqJMP+LNuTsoeiJjojYtEA S90PjE3iyUfhBnWvcXsCDkjtzN5/89X7j1KgyVmIDkXfUUwVe4i1fVUn3Xa4iWbe5xV2 gBeVBJNv5cpLyAFEN73Y4TDZs7CCso+VVfLfPNbSd9xiHKyDrYuawjkfseFJrOBsoeW+ G7pbvoXS7p/wUOIG/li/kV5DStFJtrpFkWGNuzMQDiubYStmzDvlvV+kTMARokGqcYof Ct8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708641626; x=1709246426; 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=rrbPrUW0ZTICdu2T6tV53S8IPihVOgjh3KZxbVHsClY=; b=EyMkrFeMibsK0C1yQKInGVgpp54xT2jZZzl0gSoy744S0caN02LXqt8SMQqCIalCsr eDYzKIhjNRpccsMkczaEzAjs2k9kC85eJ5bfVUKepH/d9oC6avYCGxqjxCxfSFPVLdm3 3yefs3PtrDx8JqcpE7sn5mj9rsawK10JNlBGnNCxI2qeCKTkC7izMS6dQEaw98wFNEai lqrjjZqIfG5IgkzRmov4pEbaDmLtLgExgfItS9levVikMBsCZG3yZLacfLHqwWca0XOV 1fxb3/kmq+CRhHtUClCWKN4TR/GZC4rspL6pm7l0tPTD3xhKbflrebyCQ5IYCMPUrukO XEHQ== X-Forwarded-Encrypted: i=1; AJvYcCUF6oJDkhzajtxftj+O3LK/Qyx65D6w7ZnqGCVG0MrsdZ4MsxMs+922Mk/uvOC956+xVgPySqahwlsOJsjwuSCjAQfshOBAjSxbavhEgufp/x2b/moaAFf7HXr/vM6yPzqc/MCfIROy5O4pBak5l+wDenktC3Ie/0CprEE3skJLpOpANpnqQVdWWfPZsN8PtzsV/ZGFEK6hy4wcQKSfKYP5WouRndA= X-Gm-Message-State: AOJu0Yx+gvOI3v7d6pJ52g4vLp0lfvMd9rVzbbTGThU8dq4roGubhVPm YjmNBwV/frkYtE83t8S2VYZDhopXhNo0PgothxQZlQJyqbfeA3hS X-Received: by 2002:adf:db4d:0:b0:33d:3ab8:2da7 with SMTP id f13-20020adfdb4d000000b0033d3ab82da7mr294318wrj.11.1708641625699; Thu, 22 Feb 2024 14:40:25 -0800 (PST) Received: from [192.168.1.94] (host-176-36-0-241.b024.la.net.ua. [176.36.0.241]) by smtp.gmail.com with ESMTPSA id un8-20020a170907cb8800b00a3fa6a322adsm457653ejc.56.2024.02.22.14.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 14:40:25 -0800 (PST) Message-ID: <818e43447651af1a659993897c14d05fec5038e4.camel@gmail.com> Subject: Re: [PATCH RFC bpf-next v3 04/16] bpf/helpers: introduce sleepable bpf_timers From: Eduard Zingerman To: Benjamin Tissoires , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Jonathan Corbet , Shuah Khan Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Date: Fri, 23 Feb 2024 00:40:23 +0200 In-Reply-To: <20240221-hid-bpf-sleepable-v3-4-1fb378ca6301@kernel.org> References: <20240221-hid-bpf-sleepable-v3-0-1fb378ca6301@kernel.org> <20240221-hid-bpf-sleepable-v3-4-1fb378ca6301@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/NCHuLaDeH4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28w+HKF5qoRB8/L1ZW/brlXkNzA6SveJhCnH7aOF0Yezl6TfX27w1CW5Xmvfi7X33V/SPvo0tY1THrO1c+bOjt5F+2/K3tvejmXMS/I6URwa8n1e767y5ErFKyXAYRweE9zarEgpNZTuSIGNNAqK+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 Wed, 2024-02-21 at 17:25 +0100, Benjamin Tissoires wrote: [...] > @@ -1282,7 +1333,7 @@ BPF_CALL_3(bpf_timer_start, struct bpf_timer_kern *= , timer, u64, nsecs, u64, fla > =20 > if (in_nmi()) > return -EOPNOTSUPP; > - if (flags & ~(BPF_F_TIMER_ABS | BPF_F_TIMER_CPU_PIN)) > + if (flags & ~(BPF_F_TIMER_ABS | BPF_F_TIMER_CPU_PIN | BPF_F_TIMER_SLEEP= ABLE)) > return -EINVAL; > __bpf_spin_lock_irqsave(&timer->lock); > t =3D timer->timer; > @@ -1299,7 +1350,10 @@ BPF_CALL_3(bpf_timer_start, struct bpf_timer_kern = *, timer, u64, nsecs, u64, fla > if (flags & BPF_F_TIMER_CPU_PIN) > mode |=3D HRTIMER_MODE_PINNED; > =20 > - hrtimer_start(&t->timer, ns_to_ktime(nsecs), mode); > + if (flags & BPF_F_TIMER_SLEEPABLE) > + schedule_work(&t->work); > + else > + hrtimer_start(&t->timer, ns_to_ktime(nsecs), mode); It looks like nsecs is simply ignored for sleepable timers. Should this be hrtimer_start() that waits nsecs and schedules work, or schedule_delayed_work()? (but it takes delay in jiffies, which is probably too coarse). Sorry if I miss something.