Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3804255ybk; Tue, 19 May 2020 13:21:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6Yw2r3H0ufC32KtsXTYjNeJSlNG5H9FoS658CBZKdOp2esw1G9fI7XzMSXWJh+z1AATKg X-Received: by 2002:a17:906:94c6:: with SMTP id d6mr994512ejy.88.1589919711221; Tue, 19 May 2020 13:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589919711; cv=none; d=google.com; s=arc-20160816; b=unTuUMGMLh6mKbRQkVWXj8BSwQCbnQHogNVqd0Kwf6CE/kCv18WFVyu93yxz5eDTZ6 H8VkPg40nmZ0wMvHxZyX93F+yY9enDDN7NxkrdOl/o1fcLba4xs9HiMlW5Bde8Ris2Np 6+oZXNQgdF2NXtPaVgic/p7cd3UVf3KWsPEimD1/EeAJd2rZI8e8j1YpFIqfa8XtUn/7 HGtvO9ltDLEnaXysolDFfRnOqryn/p6YZJUGbF9DA/1+7JZ32zM36XxOaHTfGI5ekpu3 ISk7REO339FVD0MBAmi7IKbyTFRCu2pMJPb6HTA0Yc2m+7vhQwcTjKqDq59Ocx6eb8tv 9vnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=b8s+uT26dwPGB+CJ0mwulfSzpNHeA7fJlnVmcOEem4A=; b=azf/XuFjjhkv2x0ajYTz59vN2paPIZe9Umn0sO7ubPhggJIOEwZg4+eXyOgBAMdvHE HqX+QZ9mGqCoYUotEklm9AR/CxqDSKSMtg2sslYyH58fudI4LiTZ21nyLiHV/mQfSUCy 8/g8b2KzbobglYYnUm7YqC7TVHtrfkRfHGIqO33AGIT4XeFjLdlK5Yzdwmu8aKnuiszX aLyCT/UKDJ23g3uds/4GoVrPc+ZDK09Gbd0IxGO/feK1IMVQkGVQ6IApY5BtOseTQQv2 p6TV0d3yEGr6p1c4OWjBHhS8Az8iG59VR+e+wKz1YVSbvhqr8s7ceWJFHjg8JIuIdCHi QWoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si487217ejj.742.2020.05.19.13.21.28; Tue, 19 May 2020 13:21:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727034AbgESUTZ (ORCPT + 99 others); Tue, 19 May 2020 16:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbgESUTZ (ORCPT ); Tue, 19 May 2020 16:19:25 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76FBDC08C5C0 for ; Tue, 19 May 2020 13:19:25 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=flow.W.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1jb8hv-00012c-0o; Tue, 19 May 2020 22:19:23 +0200 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Steven Rostedt , Will Deacon , Thomas Gleixner , "Paul E . McKenney" , Linus Torvalds Subject: [PATCH 0/8] Introduce local_lock() Date: Tue, 19 May 2020 22:19:04 +0200 Message-Id: <20200519201912.1564477-1-bigeasy@linutronix.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org preempt_disable() and local_irq_disable/save() are in principle per CPU big kernel locks. This has several downsides: - The protection scope is unknown - Violation of protection rules is hard to detect by instrumentation - For PREEMPT_RT such sections, unless in low level critical code, can violate the preemptability constraints. To address this PREEMPT_RT introduced the concept of local_locks which are strictly per CPU. The lock operations map to preempt_disable(), local_irq_disable/save() and the enabling counterparts on non RT enabled kernels. If lockdep is enabled local locks gain a lock map which tracks the usage context. This will catch cases where an area is protected by preempt_disable() but the access also happens from interrupt context. local locks have identified quite a few such issues over the years, the most recent example is: b7d5dc21072cd ("random: add a spinlock_t to struct batched_entropy") Aside of the lockdep coverage this also improves code readability as it precisely annotates the protection scope. PREEMPT_RT substitutes these local locks with 'sleeping' spinlocks to protect such sections while maintaining preemtability and CPU locality. The following series introduces the infrastructure including documentation and provides a couple of examples how they are used to adjust code to be RT ready. Sebastian