From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36B14BA50 for ; Thu, 9 Jan 2025 03:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736394373; cv=none; b=pJmSeiuHzZ0/9RSQjifiKXQU80jHsDvTjkjBvk/L7+ejQSbAKFhN7xCsZ9WtZiSLlSLBHpEBWVEBUzK2W5fCnTVGX++RskvGgwuUYuTRbB7mQ8M6fExRV7Oh9ANDJ5sEi/Z4+4jPea+5oLuBhDR1Hcd4eO4Uj8MLa7nwqnyWoX0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736394373; c=relaxed/simple; bh=WXVIr2digdx5p3er+7eiKKAk+PQhhNJhyV5n03pDSrQ=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=lKCQRfuiGvNSthgZAKJ9BwkZYXF1TnODoRdq1wPV9cKw0DRJrpvYMfCTbmbZNh4P1NyvGD8rgJtWRsLlqwgMOhzeVP8W6xuK4cy4z4LZOg9OBwOkQJ59vTMPnMHWPCqjojcU+WGehZo+MPbhat+QdvjQUhbAeFco9Jd86le5vKY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Kp5UDYW/; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Kp5UDYW/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736394370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fOoJqgw7H4gT9upPWqUMI30gXFp9tkLWAp3YieM9UKU=; b=Kp5UDYW/Skh8uAYq8sJI2DtRCAHQyFg7IWUsSVDUmTwsV9sO/3luxzNdHH25Dof0bZK6LH OpmrBH2SN/MOQH2IPWO49h5PzVG1MNvckHYsakyjdEhiMzqLCXcU38t5AX8UsqkBza8Tvk MUA7RpTminYrvOPX2F6DLsrLTiRy8Dg= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-nK-OdS13PV687KSxWYh4Zg-1; Wed, 08 Jan 2025 22:46:09 -0500 X-MC-Unique: nK-OdS13PV687KSxWYh4Zg-1 X-Mimecast-MFC-AGG-ID: nK-OdS13PV687KSxWYh4Zg Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6d8f6903d2eso9305506d6.2 for ; Wed, 08 Jan 2025 19:46:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736394368; x=1736999168; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fOoJqgw7H4gT9upPWqUMI30gXFp9tkLWAp3YieM9UKU=; b=og/ma9SoVbKqMzty21IOXrWUL8GycDt5NtuzkeUpTvceoaDRdfg5hI3wx9Uer8QVqJ rX8auav4weardCn9zAp2H1XUm98BatM8sL4Kqq2KdVGrkXcCSc0rHFdHcyzkHDfk70qj F6ot9MpDjpcNVCK2ZeuMkTlQA72FV16Dx2wCFmoWOI7ISlH+Vq7QsRPueto/w7B3xA3k EhqWcEBjxOt9/06Y5aKQpXLNMwH1CGAA31J3fFl7pJyj+PO+i9fPNLj9AvyEnR/UTnQI y6H1oQimTusrSJ6XnEkzSjD4sOYr2kX9SAM0ER5LN7fFBuEScqqF3ToIw0dRfL3pLBHN a9cw== X-Forwarded-Encrypted: i=1; AJvYcCXt87bhXCnw5sh5X34PD7NTZqQJ/YLD9SrPZ7y24OfZku5yCO7YXn4USCVRSnMVhmSBETjNOgBDbsxwrPY=@vger.kernel.org X-Gm-Message-State: AOJu0YwMC6F48iTRj8BAzDJfDE5k+HaQFOv6fdlVexREZocZAV3nZl+3 g9ujNdXciF+V0zLjbv3QLLHewgsUEKiWf8mbIfYDrq3YN9oukyzGvHmDrva3SsSXL1syw8GWPUH 0opNkExHGx1p99KUVpWxegyKZ9ad0ALffyisP2h03tIWiBqUdNWwLukY0oF/fIDVoaLYi3A== X-Gm-Gg: ASbGncvr8IP+QF4x/9x9sqm5Jaqy+ict14nUOoS7xZVccVSL9NPrc7MV8W69TjXDz7N gLGUJSm9BLvaYTnB65MzLkQjPKsv53IGpljXQuJTzvA4QdejvvDrBahgmw5k9oHAz7m97V61MDp KaphpuGiBLGKhsej275BSPTjc+jnihkRQU+Wd/I+gKEUMwl2tNXtKDeIQOasbF0OdfHjB36FAl9 uIZM26ivNd42nvyzQlEqDS3kLLvp3dqvExaUA4K7WrZUlAQseikCx1wVnH0eF6Kh4RHEXqXejhV qAai82I6isl3dubvPQM5SYMK X-Received: by 2002:a05:6214:29e5:b0:6d4:257a:8e with SMTP id 6a1803df08f44-6df9b1f6e24mr84217336d6.4.1736394367960; Wed, 08 Jan 2025 19:46:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoDUb1PfWKp3bjM8S3e3J6XpvngMEjZw7EdKwSrsCt8MxnGCiP9QUPT03qVWxXQSb3A5gRHA== X-Received: by 2002:a05:6214:29e5:b0:6d4:257a:8e with SMTP id 6a1803df08f44-6df9b1f6e24mr84217046d6.4.1736394367648; Wed, 08 Jan 2025 19:46:07 -0800 (PST) Received: from ?IPV6:2601:188:ca00:a00:f844:fad5:7984:7bd7? ([2601:188:ca00:a00:f844:fad5:7984:7bd7]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6dd7d3bfa41sm120352076d6.99.2025.01.08.19.46.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jan 2025 19:46:06 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: <0c239aaf-ad07-4be2-a608-0d484bc7fe95@redhat.com> Date: Wed, 8 Jan 2025 22:46:04 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH bpf-next v1 12/22] rqspinlock: Add basic support for CONFIG_PARAVIRT To: Alexei Starovoitov , Waiman Long Cc: Kumar Kartikeya Dwivedi , bpf , LKML , Linus Torvalds , Peter Zijlstra , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Eduard Zingerman , "Paul E. McKenney" , Tejun Heo , Barret Rhoden , Josh Don , Dohyun Kim , Kernel Team References: <20250107140004.2732830-1-memxor@gmail.com> <20250107140004.2732830-13-memxor@gmail.com> <2eaf52fb-b7d4-4024-a671-02d5375fca22@redhat.com> <7f1c3db7-a958-4bb5-b552-a20fb5b60a2e@redhat.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/8/25 10:37 PM, Alexei Starovoitov wrote: > On Wed, Jan 8, 2025 at 6:58 PM Waiman Long wrote: >> >> On 1/8/25 9:42 PM, Alexei Starovoitov wrote: >>> On Wed, Jan 8, 2025 at 4:48 PM Waiman Long wrote: >>>> Is the intention to only replace raw_spinlock_t by rqspinlock but never >>>> spinlock_t? >>> Correct. We brainstormed whether we can introduce resilient mutex >>> for sleepable context, but it's way out of scope and PI >>> considerations are too complex to think through. >>> rqspinlock is a spinning lock, so it's a replacement for raw_spin_lock >>> and really only for bpf use cases. >> Thank for the confirmation. I think we should document the fact that >> rqspinlock is a replacement for raw_spin_lock only in the rqspinlock.c >> file to prevent possible abuse in the future. > Agreed. > >>> We considered placing rqspinlock.c in kernel/bpf/ directory >>> to discourage any other use beyond bpf, >>> but decided to keep in kernel/locking/ only because >>> it's using mcs_spinlock.h and qspinlock_stat.h >>> and doing #include "../locking/mcs_spinlock.h" >>> is kinda ugly. >>> >>> Patch 16 does: >>> +++ b/kernel/locking/Makefile >>> @@ -24,6 +24,9 @@ obj-$(CONFIG_SMP) += spinlock.o >>> obj-$(CONFIG_LOCK_SPIN_ON_OWNER) += osq_lock.o >>> obj-$(CONFIG_PROVE_LOCKING) += spinlock.o >>> obj-$(CONFIG_QUEUED_SPINLOCKS) += qspinlock.o >>> +ifeq ($(CONFIG_BPF_SYSCALL),y) >>> +obj-$(CONFIG_QUEUED_SPINLOCKS) += rqspinlock.o >>> +endif >>> >>> so that should give enough of a hint that it's for bpf usage. >>> >>>> As for the locking semantics allowed by the BPF verifier, is it possible >>>> to enforce the strict locking rules for PREEMPT_RT kernel and use the >>>> relaxed semantics for non-PREEMPT_RT kernel. We don't want the loading >>>> of an arbitrary BPF program to break the latency guarantee of a >>>> PREEMPT_RT kernel. >>> Not really. >>> root can load silly bpf progs that take significant >>> amount time without abusing spinlocks. >>> Like 100k integer divides or a sequence of thousands of calls to map_update. >>> Long runtime of broken progs is a known issue. >>> We're working on a runtime termination check/watchdog that >>> will detect long running progs and will terminate them. >>> Safe termination is tricky, as you can imagine. >> Right. >> >> In that case, we just have to warn users that they can load BPF prog at >> their own risk and PREEMPT_RT kernel may break its latency guarantee. > Let's not open this can of worms. > There will be a proper watchdog eventually. > If we start to warn, when do we warn? On any bpf program loaded? > How about classic BPF ? tcpdump and seccomp ? They are limited > to 4k instructions, but folks can abuse that too. My intention is to document this somewhere, not to print out a warning in the kernel dmesg log. Cheers, Longman