From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (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 E173235C1AD for ; Mon, 25 May 2026 19:49:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779738588; cv=none; b=DPVnegjoHeJv/HtqM+n+MWUhus62teShk2tb1kXnJXeTNOvTcFE9SsyUcla4A9c695TR2dndPoBXW0Fbh6luEVV0ThqrIbI/g0oU7Zxo20g4SNpzB+/hwC/SzRHqN/eo2A17UyFOWbljyZjOEcihtAZHz5mWSpRNaL8oGKS0im8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779738588; c=relaxed/simple; bh=hN2gTsGG00WZfAJH7F3jeYvGlvKV+w5hhNPlto0mhTw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=C6X4S5WTIOp78A4d+Y7KzInBukvNB4W18Wb0mTYH/pP74avoxXIVGraa8VoX26qZHPDZ/3it0LKA51hM6DpMP5azL9HWl13vEGLDIwybF2k5hYspy3Ndz1OHZiFVcenbDY2AMGx9M4jGNMovo1kG6KH0VLmb4PIq21Kpz4uL6JU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wbinvd.org; spf=pass smtp.mailfrom=wbinvd.org; dkim=pass (2048-bit key) header.d=wbinvd.org header.i=@wbinvd.org header.b=GV+8IbN7; arc=none smtp.client-ip=74.125.82.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wbinvd.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wbinvd.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wbinvd.org header.i=@wbinvd.org header.b="GV+8IbN7" Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-2bdcf5970cdso6910005eec.0 for ; Mon, 25 May 2026 12:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wbinvd.org; s=wbinvd; t=1779738585; x=1780343385; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8Yu9d6gTXgdP6EK+2IYW5F5Xve/jIZBNQFenXapvxDA=; b=GV+8IbN7S3AmAUKRcnBW6xLYGb2D9aBj6L+xl1dthVdIrxsgKGrLOGrH5fAwwVnDfs DPT0Sg42onjHX+87iv8f06NAxbfXjrQcq2RfS3wYnM43llSt8EE1S7L3Z5SoeXsjW+oN NHIO8PMTuqE8Gv1zc6Wn2QDjNd7FhTmK3yujPILdK7kkEImJcnFtF1WmxmYJxkzzfKa+ YqwPYtN/328OaHQnCTiCkO7UBfQ0rJP/pNlFlzOp1Rl92DhsLR4aoB0S6mfYfvYmsGq0 MYFtyzwAzwp6xXRVeVJfcWULiSK76os9zFC+hRV2M3uJ5JSPcMHWOOBp01Um3dwTsjqS CTcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779738585; x=1780343385; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8Yu9d6gTXgdP6EK+2IYW5F5Xve/jIZBNQFenXapvxDA=; b=dGCRTszhZJUfYulZiXz3hYII26Ix70IllAB/C2hMppsL9Q4fITYBzhxKq8i6rmkziQ QFHQqxjZSRnLLCMGrla3vk8Iu9GGPjPa/IhXDoHXQ9p2/QfNSrbYExS4OOjTac6uEN5j 3NO31K6+IJqPkt3indLioSuoj/AKAzqi0jwekHIOmVcYiXUU92fn/a4mjU/7shWSbkN4 4STlsw1tdDC7tH0kNJIEgQvfxJLZ6Rlo5odHQPqhY2PcaEjpE8gkP/bKM1MPY88zyef9 nK9U5Wrv9rFHabm6wRAohzqbgi15dif3/VLSJVKd94JzoFC1Y+07+6sAzZowKLBbikZo Sa9w== X-Gm-Message-State: AOJu0YyjUA35aOLjR05A/zKgDUMTmtX3mhXzo4IyJETW4v6+M0hAh/2K rUio/QW7hUavZlzB46iB6tDCYxmQTCXisywzsmAuJOakHM45DlkXI7OAnjkdo/wrdevYcCTqDGl De4dW X-Gm-Gg: Acq92OGK4v4Rd7DIRJPao3bLm8kORKxWdg6YPzwA14FmFseUrcBt4qY04SOUDavNbTt 55u0ySg0DQVWBPcVzjDyI4miFNK8VSlI7xNnTouG2/W1ZofnYMnqN6MHZ8qFhaJ7taPxg8eVhx+ 921v8YhUf+JQzxwRGwSxlk7sMYoPuxcUeIc06kMKKKrHGvOSf6ufE8dlXfM7/anOHj8ppDDimRF ++ADemTTW0h/BIC4MdmQ+q2nMjEu0qXvrrLd0SLnCxhpIms9wDlndPMCUPMfpr58KU7ygokdywO vPgvzPUE2MzXPBclsZSeNu9z3Y3mng9S3Ti8VJi9+cA6B8dulNiLqR3MfgmSMJl1bj32HEJ1dAG c+pXw1Njdc6ZGcCnrlmeS5x0H/ArCTEw0EpAnCjxAeR+YcGY8vPyMcJ+uRrcZyPV6xSvOxzPdbs FqfnQj3cVeC6ubiafRILL5L5GRGA== X-Received: by 2002:a05:7301:418b:b0:2de:e194:5fb1 with SMTP id 5a478bee46e88-3044a41ceacmr5620399eec.7.1779738584945; Mon, 25 May 2026 12:49:44 -0700 (PDT) Received: from mozart.vkv.me ([2001:5a8:468b:d015:2feb:307b:ed4b:5f1d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30452230dddsm11032141eec.17.2026.05.25.12.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 12:49:44 -0700 (PDT) From: Calvin Owens To: linux-kernel@vger.kernel.org Cc: Rodolfo Giometti , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Thomas Gleixner , Ingo Molnar , Greg Kroah-Hartman , Michael Byczkowski , Eliav Farber , linux-rt-devel@lists.linux.dev, David Laight Subject: [PATCH v6 0/3] pps: improve PREEMPT_RT performance Date: Mon, 25 May 2026 12:49:29 -0700 Message-ID: X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hello all, Michael is busy, and I have some extra bandwidth, so I've volunteered to help out with the patch schlepping here. These v6 patches are based on 7.1-rc5. This is all Michael's work, and Michael's cover letter follows. I added lore links to the older patch versions next to his change descriptions. Note that I replaced two emdashes in comment blocks with regular hypens in patch 1/3, to avoid 8bit encoding. Thanks, Calvin --- From: Michael Byczkowski This is v6 of the PPS PREEMPT_RT patchset, addressing the review feedback from Sebastian Andrzej Siewior on v5. Changes since v5: https://lore.kernel.org/lkml/719A31CE-CA58-45C3-A013-1BFE81F724C5@by-online.de/ - Reordered: the pps_kc_hardpps_lock conversion now precedes the pps_device.lock conversion. The previous order would have briefly produced a raw_spinlock holding a sleeping spinlock on PREEMPT_RT (Sebastian). - Patch 1/3: commit message reworded to describe the handler split structurally first, then its PREEMPT_RT benefit (Sebastian). - Patch 2/3: refactored pps_kc_bind() and pps_kc_remove() to use guard(raw_spinlock_irq) for scope-based lock release. Eliminates four duplicated unlock call sites in pps_kc_bind() and the ambiguous bracket structure that resulted from them (Sebastian). - Rodolfo's Acked-by on patch 2/3 is preserved from v5; the guard() refactor is purely stylistic and was suggested by Sebastian, but please re-ack or NAK if disagreement. Changes since v4: https://lore.kernel.org/lkml/B24484C5-3117-4C56-9522-1EE9876E64BA@by-online.de/ - Patch 2/3: added Acked-by: Rodolfo Giometti Changes since v3: https://lore.kernel.org/lkml/83318241-44C3-48BE-829D-5C5F82A78A74@by-online.de/ - Patch 2/3: fixed lost indentation on pps_kc_event() call (reported by Rodolfo Giometti ) Changes since v2: https://lore.kernel.org/lkml/1BB87C0C-33C1-45C3-B50E-C5F349DA3FDC@by-online.de/ - Patch 2/3: moved wake_up_interruptible_all() and kill_fasync() out of raw_spinlock section to avoid sleeping-in-atomic on PREEMPT_RT (reported by Nikolaus Buchwitz ) This patchset addresses three sources of PPS jitter under PREEMPT_RT, while being fully backward-compatible with non-RT kernels: 1. pps-gpio: The IRQ handler is force-threaded on PREEMPT_RT, so the PPS timestamp is captured after scheduling delay rather than at interrupt entry. Fix: split into a hardirq primary handler (captures timestamp only) and a threaded handler (processes the event). 2. pps_kc_hardpps_lock: spinlock_t becomes a sleeping mutex on PREEMPT_RT. Since pps_kc_event() calls hardpps() under this lock and hardpps() takes the raw_spinlock_t tk_core.lock, the nesting is invalid. Fix: convert to DEFINE_RAW_SPINLOCK. 3. pps_device.lock: same issue as (2), in the PPS event delivery path. Fix: convert to raw_spinlock_t and move sleeping calls out of the critical section. All three patches are tested on a Raspberry Pi 5 running 7.0.1 and 7.1-rc PREEMPT_RT kernels. On non-RT kernels there is zero behavioral change. Michael Byczkowski (3): pps: pps-gpio: split IRQ handler into hardirq timestamper + threaded handler pps: kc: convert pps_kc_hardpps_lock to raw_spinlock_t pps: convert pps_device.lock to raw_spinlock_t drivers/pps/clients/pps-gpio.c | 37 +++++++++++++------ drivers/pps/kapi.c | 6 +-- drivers/pps/kc.c | 67 ++++++++++++++++------------------ drivers/pps/pps.c | 16 ++++---- include/linux/pps_kernel.h | 2 +- 5 files changed, 68 insertions(+), 60 deletions(-) -- 2.47.3