Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp131371imm; Thu, 2 Aug 2018 15:27:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe04fbZczAhwM5Uv/IspvREGr2ym2IlnWqbrqvP29H6/Wb2wNujonIn+Qv5CoNgEXXMYAVw X-Received: by 2002:a17:902:724c:: with SMTP id c12-v6mr1076722pll.326.1533248864651; Thu, 02 Aug 2018 15:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533248864; cv=none; d=google.com; s=arc-20160816; b=BxlSHYsFyXjW7J1be8KkKsifIxKAe97ScVVv+at9F7ECcBlw/sjbtpEbMpwQGvdl+v TlpGiOTPpQPOTBZRWvPaMlf0DKWo5HaRrQ6L6+Yz3daEWdgQH8SZrooKefl9+G7dBXks bWgnG4J7dsPqkMH2Jx7VOjtWLqlC+fC1dRor0wEjKolyruKdIX52QnsNnbDATtXYYdDF /A6wrSc/UcAKARhUJXClZbBt7h/NiBpQnOWC/CJj8U4oEwMY8G6BhK/dPQHhjmI3JNSD xOkvz1zeYzwDRw8RKNphGtRN+SInC66qbM4ooSGrvd4Sz6ifa6gzqQsNWP9B7EQBZBXP ZfBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zv/Orwv6GdlFFgdEkL/ci+DSeDmvJ1k9SppYI4XIV/0=; b=mA1fbl8r5vJyRRpXjObOl6l3h36dKLDoroqkbvEHUPJjjfmh5souCKux8xz73/6MqR tg0D4gEC8TS+Tw3OyNhXgm3EU70/B7ZdzcAeJOjhTYkEFokEgNkWSmu504BPOQLXiSG7 b/O/rjuu9hea03Jr2A2wav2yrO39p9C1bYKLwEJKWNzWRw+w537DGa1d3kyu62F1kjLJ 2jC6dyL12SBcqb+ILV4qLkMs+JMAn10athsAodyhSK9S0DHQOKeRurjcszJBDKtntWU2 fc+/06zp/KUeNOfeQ9G0aA6FQ3srDh+OaokGwq8Uwea1NG2fEVbl6MGxvfKWsz4QSnrZ RMoQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g202-v6si3388619pfb.336.2018.08.02.15.27.30; Thu, 02 Aug 2018 15:27:44 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732067AbeHCATh (ORCPT + 99 others); Thu, 2 Aug 2018 20:19:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:34820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbeHCATh (ORCPT ); Thu, 2 Aug 2018 20:19:37 -0400 Received: from localhost.localdomain (c-98-220-238-81.hsd1.il.comcast.net [98.220.238.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 977B7215E4; Thu, 2 Aug 2018 22:26:25 +0000 (UTC) From: Tom Zanussi To: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Cc: rostedt@goodmis.org, tglx@linutronix.de, C.Emde@osadl.org, jkacur@redhat.com, bigeasy@linutronix.de, daniel.wagner@siemens.com, julia@ni.com, stable-rt@vger.kernel.org, Daniel Wagner , Tom Zanussi Subject: [PATCH 03/15] posix-timers: move the rcu head out of the union Date: Thu, 2 Aug 2018 17:25:18 -0500 Message-Id: X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior 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 Signed-off-by: Daniel Wagner (cherry picked from commit 57f93c5f597fa32af860321c5bca34bc5ffe08e1) Signed-off-by: Tom Zanussi --- 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 907f3fd191ac..e2e43c61f6a1 100644 --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -92,8 +92,8 @@ struct k_itimer { struct alarm alarmtimer; ktime_t interval; } alarm; - struct rcu_head rcu; } it; + struct rcu_head rcu; }; struct k_clock { diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index b5e0ff549422..bdf91054e6c3 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -560,7 +560,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); } @@ -577,7 +577,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 struct k_clock *clockid_to_kclock(const clockid_t id) -- 2.14.1