Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1640131pxy; Mon, 2 Aug 2021 06:52:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxeKPApAOBgKW8PttiUYmfgA0WghzMGRyb9WeVS8s6KqE0xHMxHPfiDWZCc1BnYWOBXr4a X-Received: by 2002:a05:6638:d51:: with SMTP id d17mr15274506jak.109.1627912356370; Mon, 02 Aug 2021 06:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912356; cv=none; d=google.com; s=arc-20160816; b=z491C4eqqBBh3IVr6FsaVRrfhzxqte5wBFJNMMTzAjF8WZdEitVWWTbCoORA8pWauR +FEpwmvnHYIoGw9FwCBqSJsZgI9SKtuhN6YIZE/WAiLyRHRqkxg5obd9g2nbsbMrN98P +2q1jbaHZKdkHEPaLR/sXMZrPrxGXdqWGuZT+0baX+HydR5V5obAUxSkL5BeOHTPml7R 0NBQ+ere+WfwboPYQisrYC1BGefGtqJSUtBKts9EN9PG1iMwSMuuJMYGZnrfGClDr8Qn dT0W0rtx3OZCMFNwDwBGd/VbL3FcN7Y+GWMxbwAOY8LVkdARXBtOIRJGdwd8mufstd+h GT8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1HCNEA5pO/D+tifD4psbwI94Vq0NxAvY0x4XDUj6beE=; b=q7AbmHXrO2vr3G5Fv8LRnJjkIvL6HxwHaBtCLeCrt7kakOwf9HcLWm0h80wkKyDjuu W1Q+clRjtwzN0Wkxbm40ca7sMVnR8kivuPQksnuFbBsj1wQrF5BtI0jwIWnVjBx9E6eY YAEES9LhGNmRMhyVTbegqQ5eNqG12rLkvLo35Lio45N/CmEdhyp4FRVzx53DkAOBOA9A lfXp8fdp6RB9sWk9crELIF3eoCi1gx2p3QRnzzhNe1kYb4d/VFnptO2qEGKzDBTDUjDE STkA3FkC0IemH98aMO95IVCS8VmIxR2rUfsRHfLm2BV2nOcbooLfWhmSWE0sAYie3zPp 07TA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m38si5652970jav.99.2021.08.02.06.52.25; Mon, 02 Aug 2021 06:52:36 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234993AbhHBNvy (ORCPT + 99 others); Mon, 2 Aug 2021 09:51:54 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:12339 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234008AbhHBNrg (ORCPT ); Mon, 2 Aug 2021 09:47:36 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GdfM44YkVz81wX; Mon, 2 Aug 2021 21:42:24 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 2 Aug 2021 21:47:13 +0800 Received: from thunder-town.china.huawei.com (10.174.179.0) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 2 Aug 2021 21:47:13 +0800 From: Zhen Lei To: Greg Kroah-Hartman , stable CC: Zhen Lei , Anna-Maria Gleixner , Mike Galbraith , Sasha Levin , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , linux-kernel Subject: [PATCH 4.4 03/11] futex,rt_mutex: Introduce rt_mutex_init_waiter() Date: Mon, 2 Aug 2021 21:46:16 +0800 Message-ID: <20210802134624.1934-4-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20210802134624.1934-1-thunder.leizhen@huawei.com> References: <20210802134624.1934-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.179.0] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit 50809358dd7199aa7ce232f6877dd09ec30ef374 ] Since there's already two copies of this code, introduce a helper now before adding a third one. Signed-off-by: Peter Zijlstra (Intel) Cc: juri.lelli@arm.com Cc: bigeasy@linutronix.de Cc: xlpang@redhat.com Cc: rostedt@goodmis.org Cc: mathieu.desnoyers@efficios.com Cc: jdesfossez@efficios.com Cc: dvhart@infradead.org Cc: bristot@redhat.com Link: http://lkml.kernel.org/r/20170322104151.950039479@infradead.org Signed-off-by: Thomas Gleixner Signed-off-by: Zhen Lei --- kernel/futex.c | 5 +---- kernel/locking/rtmutex.c | 12 +++++++++--- kernel/locking/rtmutex_common.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index dab9c79a931a23e..53a085a378f3844 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -3156,10 +3156,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags, * The waiter is allocated on our stack, manipulated by the requeue * code while we sleep on uaddr. */ - debug_rt_mutex_init_waiter(&rt_waiter); - RB_CLEAR_NODE(&rt_waiter.pi_tree_entry); - RB_CLEAR_NODE(&rt_waiter.tree_entry); - rt_waiter.task = NULL; + rt_mutex_init_waiter(&rt_waiter); ret = get_futex_key(uaddr2, flags & FLAGS_SHARED, &key2, VERIFY_WRITE); if (unlikely(ret != 0)) diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 1c0cb5c3c6ad6fe..fa24df4bc7a8ff0 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1155,6 +1155,14 @@ void rt_mutex_adjust_pi(struct task_struct *task) next_lock, NULL, task); } +void rt_mutex_init_waiter(struct rt_mutex_waiter *waiter) +{ + debug_rt_mutex_init_waiter(waiter); + RB_CLEAR_NODE(&waiter->pi_tree_entry); + RB_CLEAR_NODE(&waiter->tree_entry); + waiter->task = NULL; +} + /** * __rt_mutex_slowlock() - Perform the wait-wake-try-to-take loop * @lock: the rt_mutex to take @@ -1236,9 +1244,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, struct rt_mutex_waiter waiter; int ret = 0; - debug_rt_mutex_init_waiter(&waiter); - RB_CLEAR_NODE(&waiter.pi_tree_entry); - RB_CLEAR_NODE(&waiter.tree_entry); + rt_mutex_init_waiter(&waiter); raw_spin_lock(&lock->wait_lock); diff --git a/kernel/locking/rtmutex_common.h b/kernel/locking/rtmutex_common.h index 4584db96265d429..0424ff97bb69cad 100644 --- a/kernel/locking/rtmutex_common.h +++ b/kernel/locking/rtmutex_common.h @@ -102,6 +102,7 @@ extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock); extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock, struct task_struct *proxy_owner); extern void rt_mutex_proxy_unlock(struct rt_mutex *lock); +extern void rt_mutex_init_waiter(struct rt_mutex_waiter *waiter); extern int rt_mutex_start_proxy_lock(struct rt_mutex *lock, struct rt_mutex_waiter *waiter, struct task_struct *task); -- 2.26.0.106.g9fadedd