Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp572609img; Fri, 22 Mar 2019 04:17:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvwVTCBdaFfHu0xUUxqfmN1D6E/0PsvA4LuA/5pc0xwacGjKNJ5hO6njH4md5QhiRIdddH X-Received: by 2002:a65:624c:: with SMTP id q12mr8116800pgv.75.1553253460658; Fri, 22 Mar 2019 04:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253460; cv=none; d=google.com; s=arc-20160816; b=Q3X4xpl/yCEsMFFOkCiOJ/lR+hagPlp7ZZUkxkl5LKjmjb4Yop9mP/4gzJ/YUeQvCE wbKC7HP235Tde8ghySAz6+Sb1MTCO3eMOMB+IOf7YheXkEejPnpMeBJjHgyaK43HCacV ll4yES7dV9aS1xBL3nUCSgVfH+D3XzIV2PEsuwpkAxfYEX6M1EMM2q5kpCyR4NpO34Ya dX2P0D5lhXGUARwnBOXxdwmlBob1TgfP2d3p1dTJEY1Xu/W/HjjDBxXqpKY++WnIGg0V +GIAmtIHm2OdIMRCaJWR5DUUO8mt1QyMAT+igiKSimKLpI5sWXZMUOsy1FuengY5o41N pUxA== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ep08GtGtwgFzxgtaVrL5TR9YPTyDrVwTgR43/DxOErA=; b=f1Y8M/VulE7StyGF1tD0f3zR6j2+4CleEAQQPuEWbFue317hfQVDENQ5dwe38XrbY2 09D/Tw2Blbs2XcgyVuHixmn0NB7fQ50ZYkIvoGiA14ZF7nBQIQZw+k3Gd/jwxMajIez+ +oGj65iAlg4aZHZkEMALuiJWRnYWp6G9eyWFkBuIJb3QZWfMCAiux1Nc42qMWhMoQ/dX TNBrVI02ISDQudIrw8v6t3dyoEMdo0QtIVBD0xFWE8Q+pM7wU6EkdxlmktHqjWG3MzAi TPnNA9BW6i3GK7UawsVNJquZp4Uvs+4SSGagTpQIFivKGhFtI2II9K1a6TgilxGdm9UL 3HYA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c127si6503397pfc.256.2019.03.22.04.17.25; Fri, 22 Mar 2019 04:17:40 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728072AbfCVLQv (ORCPT + 99 others); Fri, 22 Mar 2019 07:16:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52934 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbfCVLQv (ORCPT ); Fri, 22 Mar 2019 07:16:51 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEC5B3083363; Fri, 22 Mar 2019 11:16:50 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.32]) by smtp.corp.redhat.com (Postfix) with SMTP id 41AA71A914; Fri, 22 Mar 2019 11:16:45 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 22 Mar 2019 12:16:48 +0100 (CET) Date: Fri, 22 Mar 2019 12:16:42 +0100 From: Oleg Nesterov To: Matthew Wilcox Cc: Waiman Long , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , linux-kernel@vger.kernel.org, linux-mm@kvack.org, selinux@vger.kernel.org, Paul Moore , Stephen Smalley , Eric Paris , "Peter Zijlstra (Intel)" Subject: Re: [PATCH 2/4] signal: Make flush_sigqueue() use free_q to release memory Message-ID: <20190322111642.GA28876@redhat.com> References: <20190321214512.11524-1-longman@redhat.com> <20190321214512.11524-3-longman@redhat.com> <20190322015208.GD19508@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190322015208.GD19508@bombadil.infradead.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 22 Mar 2019 11:16:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/21, Matthew Wilcox wrote: > > On Thu, Mar 21, 2019 at 05:45:10PM -0400, Waiman Long wrote: > > > To avoid this dire condition and reduce lock hold time of tasklist_lock, > > flush_sigqueue() is modified to pass in a freeing queue pointer so that > > the actual freeing of memory objects can be deferred until after the > > tasklist_lock is released and irq re-enabled. > > I think this is a really bad solution. It looks kind of generic, > but isn't. It's terribly inefficient, and all it's really doing is > deferring the debugging code until we've re-enabled interrupts. Agreed. > We'd be much better off just having a list_head in the caller > and list_splice() the queue->list onto that caller. Then call > __sigqueue_free() for each signal on the queue. This won't work, note the comment which explains the race with sigqueue_free(). Let me think about it... at least we can do something like close_the_race_with_sigqueue_free(struct sigpending *queue) { struct sigqueue *q, *t; list_for_each_entry_safe(q, t, ...) { if (q->flags & SIGQUEUE_PREALLOC) list_del_init(&q->list); } called with ->siglock held, tasklist_lock is not needed. After that flush_sigqueue() can be called lockless in release_task() release_task. I'll try to make the patch tomorrow. Oleg.