Received: by 10.192.165.148 with SMTP id m20csp73558imm; Fri, 4 May 2018 06:56:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoZh4nuKcMJ+9oVQsSjjU1F6MyqXPlZ/LH/jW13S+cgkNDxDDNPMDWuXSp4nhk+/vWX9VVW X-Received: by 2002:a63:93:: with SMTP id 141-v6mr18876982pga.322.1525442198076; Fri, 04 May 2018 06:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525442198; cv=none; d=google.com; s=arc-20160816; b=KSc3HtpwgvWlnFhoo15ZuxBpebyNHFKlBrVwmxoRgdVVSqoHLbeLRd642y0KqT4yZR gWnhkvLQjihM4W/agNzmt9qXctuIWCEJD/t2eJLG5bDbES6Iuld1j/g2waoBXdQ6DpRa /KhZK8199GItOfNoIb486IK9EJgpPhBHQyntoM+b+RSezEPX/QO0T3+G8aNWvVFrvfOI WWzcyX1IIFqLXWanl+uTMi8k98p7DferF5blAZjD+uvr5FAsn1E1/BevlQFXylzk884e xYDQuS3dbuBVte876jvMs5VyqF61Tafo5WogAkwQgDPfclvn0ocbwzGRQiYh3MhXod5k A8Qw== 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:message-id:date :subject:cc:to:from:arc-authentication-results; bh=LrJ+WulITH/4miNbR2z9wLdzXwnJNMXwWOqguADt5z8=; b=CZ7ErYp9++urEa1fu3TJNPX2mmR07lYxlg1TTMY3po/UyrMGfijiMHoYQrKASAcqQD 7i8i8ZWgSlEm4ZIBD1p2KIi8bbcoAcG8wDsiHoQtHsqRpmLPISbC0yP8R+sUDpjxpUlc uWlMLlA8QksXJp0ShML8uU2tZdwvBHqTvvf1p4Lh6pB/Dde49SmJ2ChQwe+T5LkapFXJ dwnKJZbJXXM9AMHcqvcVNaBP/JWL5gO0uh+efT1/8jAvhCCj6tw5uNkVAhI3C1pffMrg 9eaVD9t21VeXgQo8RipJOIkyR+7+Efxg5adCyK/RD75w96RcOlNeYKe+F+gM33hoBT3q PN4g== 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=monom.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si5752937pfn.87.2018.05.04.06.56.23; Fri, 04 May 2018 06:56:38 -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=monom.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752013AbeEDNz3 (ORCPT + 99 others); Fri, 4 May 2018 09:55:29 -0400 Received: from mail.monom.org ([188.138.9.77]:44034 "EHLO mail.monom.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949AbeEDNz0 (ORCPT ); Fri, 4 May 2018 09:55:26 -0400 Received: from mail.monom.org (localhost [127.0.0.1]) by filter.mynetwork.local (Postfix) with ESMTP id 2B838500E4D; Fri, 4 May 2018 15:55:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail.monom.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 Received: from localhost (ppp-93-104-183-185.dynamic.mnet-online.de [93.104.183.185]) by mail.monom.org (Postfix) with ESMTPSA id E3BBB500E4B; Fri, 4 May 2018 15:55:23 +0200 (CEST) From: Daniel Wagner To: linux-rt-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Tom Zanussi , Julia Cartwright , stable-rt@vger.kernel.org Subject: [PATCH RT 2/3] posix-timers: move the rcu head out of the union Date: Fri, 4 May 2018 15:55:15 +0200 Message-Id: <20180504135516.32601-3-wagi@monom.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504135516.32601-1-wagi@monom.org> References: <20180504135516.32601-1-wagi@monom.org> 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 --- 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 48ca053dae2e..0808e2ae49bf 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -567,7 +567,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); } @@ -584,7 +584,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.3