Received: by 10.213.65.68 with SMTP id h4csp280435imn; Wed, 28 Mar 2018 03:31:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/qyVpLpmpnfF38coqTQ5E3XEuOLbgEArExkySCDnlLzKplelRssV2bLUPVJGcsp+8cESsc X-Received: by 2002:a17:902:b905:: with SMTP id bf5-v6mr3268837plb.159.1522233119475; Wed, 28 Mar 2018 03:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522233119; cv=none; d=google.com; s=arc-20160816; b=BDfqdSUU3LdeEiID/GA06udoSrGS9NFJvei5cWD+Z9Ct5xVuvumygQQvFphmYDIMhi I3Gtqyqkh+cHx3p2mImsk2vqurG/YhjayLrMnfJ8o4Dt3oUMClMr9BN4rVdIA+OFxYH2 uXQzGAk6jFPep8TorM9C2bGtroMU00kZwkRfU75OThAtfYwOx6cGBbgVXhd5rm0NN6NZ QRdr5mDKcURysYZ6Zt0ULmP+BEYoMJmvJ28gEqCjgLspb6UZCriVYIp2sB/K1XRMHdUM olRvV2nla1CCeKRwzehKpPZ+3svPYbA963EyiPXPkIdiq+I0H4VoTHNoMiD1cvwP74MK JbdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=yQeg10QPpRnHQ0jkEPbzKhBqCyBerv+gxLji3jrEsL4=; b=kGUVZA9SHAipP+3GnJbdVrLulOgFh7eWmhHFNP0y7DTtP+jpTlfwNUU8ivkGbeo5Hq Mt9XqW2vkQUNq32hKF/7kiHG42j//IJ8hKUA3WA16pqEh5XBAWrcssZZr7YZoCVXH16c dulG02AKilAzrkO9D0+1+c+zfv4jUFoB+HjMsTQ0GFw7GWnNu26BjHEN2/frauGQyJPQ /7OBYViBn8RW3OZtxzgrLRq0kJTENvH3aeWO6uIXEP0V96sSQ0QCFuJ9jesowYP+sduy SlhMzN1TFRuYYjy2PfOb8nTNVe/i0WDfFdLooQFrHhmjxCDb/FiJX/yQtOAwfgQoqHTx JCxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n124si59970pga.53.2018.03.28.03.31.44; Wed, 28 Mar 2018 03:31:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752725AbeC1K33 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 28 Mar 2018 06:29:29 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:50249 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbeC1K32 (ORCPT ); Wed, 28 Mar 2018 06:29:28 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1f18Kc-0001SB-MH; Wed, 28 Mar 2018 12:29:26 +0200 Date: Wed, 28 Mar 2018 12:29:26 +0200 From: Sebastian Andrzej Siewior To: linux-rt-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Steven Rostedt , stable-rt@vger.kernel.org Subject: [PATCH RT 3/3 v2] posix-timers: move the rcu head out of the union Message-ID: <20180328102926.ym4ije4m2derb2ht@linutronix.de> References: <20180328100746.18668-1-bigeasy@linutronix.de> <20180328100746.18668-3-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <20180328100746.18668-3-bigeasy@linutronix.de> User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On RT the timer can be preempted while running and therefore we wait with timer_wait_for_callback() for the timer to complete (instead of busy looping). The RCU-readlock is held to ensure that this posix timer is not removed while we wait on it. If the timer is removed then it invokes call_rcu() with a pointer that is shared with the hrtimer because it is part of the same union. In order to avoid any possible side effects I am moving the rcu pointer out of the union. Cc: stable-rt@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior --- v1…v2: add the lost hunk in posix-timers.c include/linux/posix-timers.h | 2 +- kernel/time/posix-timers.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h index 672c4f32311e..4754eb4298b1 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -101,8 +101,8 @@ struct k_itimer { struct { struct alarm alarmtimer; } alarm; - struct rcu_head rcu; } it; + struct rcu_head rcu; }; void run_posix_cpu_timers(struct task_struct *task); diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 3abd449a926f..17d4eb49e7c3 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -470,7 +470,7 @@ static struct k_itimer * alloc_posix_timer(void) static void k_itimer_rcu_free(struct rcu_head *head) { - struct k_itimer *tmr = container_of(head, struct k_itimer, it.rcu); + struct k_itimer *tmr = container_of(head, struct k_itimer, rcu); kmem_cache_free(posix_timers_cache, tmr); } @@ -487,7 +487,7 @@ static void release_posix_timer(struct k_itimer *tmr, int it_id_set) } put_pid(tmr->it_pid); sigqueue_free(tmr->sigq); - call_rcu(&tmr->it.rcu, k_itimer_rcu_free); + call_rcu(&tmr->rcu, k_itimer_rcu_free); } static int common_timer_create(struct k_itimer *new_timer) -- 2.16.3