From patchwork Thu Mar 21 21:45:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 10864391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23DB51708 for ; Thu, 21 Mar 2019 21:45:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07EA82A50F for ; Thu, 21 Mar 2019 21:45:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED8992A512; Thu, 21 Mar 2019 21:45:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93A5C2A50F for ; Thu, 21 Mar 2019 21:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726727AbfCUVph (ORCPT ); Thu, 21 Mar 2019 17:45:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50664 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfCUVph (ORCPT ); Thu, 21 Mar 2019 17:45:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA86A59443; Thu, 21 Mar 2019 21:45:35 +0000 (UTC) Received: from llong.com (dhcp-17-47.bos.redhat.com [10.18.17.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 845765C8BD; Thu, 21 Mar 2019 21:45:27 +0000 (UTC) From: Waiman Long To: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, selinux@vger.kernel.org, Paul Moore , Stephen Smalley , Eric Paris , "Peter Zijlstra (Intel)" , Oleg Nesterov , Waiman Long Subject: [PATCH 0/4] Signal: Fix hard lockup problem in flush_sigqueue() Date: Thu, 21 Mar 2019 17:45:08 -0400 Message-Id: <20190321214512.11524-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 21 Mar 2019 21:45:36 +0000 (UTC) Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It was found that if a process has accumulated sufficient number of pending signals, the exiting of that process may cause its parent to have hard lockup when running on a debug kernel with a slow memory freeing path (like with KASAN enabled). release_task() => flush_sigqueue() The lockup condition can be reproduced on a large system with a lot of memory and relatively slow CPUs running LTP's sigqueue_9-1 test on a debug kernel. This patchset tries to mitigate this problem by introducing a new kernel memory freeing queue mechanism modelled after the wake_q mechanism for waking up tasks. Then flush_sigqueue() and release_task() are modified to use the freeing queue mechanism to defer the actual memory object freeing until after releasing the tasklist_lock and with irq re-enabled. With the patchset applied, the hard lockup problem was no longer reproducible on the debug kernel. Waiman Long (4): mm: Implement kmem objects freeing queue signal: Make flush_sigqueue() use free_q to release memory signal: Add free_uid_to_q() mm: Do periodic rescheduling when freeing objects in kmem_free_up_q() include/linux/sched/user.h | 3 +++ include/linux/signal.h | 4 ++- include/linux/slab.h | 28 +++++++++++++++++++++ kernel/exit.c | 12 ++++++--- kernel/signal.c | 29 +++++++++++++--------- kernel/user.c | 17 ++++++++++--- mm/slab_common.c | 50 ++++++++++++++++++++++++++++++++++++++ security/selinux/hooks.c | 8 ++++-- 8 files changed, 128 insertions(+), 23 deletions(-)