Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2076659ybi; Sun, 9 Jun 2019 03:11:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4EDDp1t1/sUWLnxv0ce4VhbXcmcaYZTuQkZphN/YEG2GpG9jeoVtEFZOgHYt8iKolqMzM X-Received: by 2002:a17:902:e409:: with SMTP id ci9mr65215512plb.103.1560075105581; Sun, 09 Jun 2019 03:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560075105; cv=none; d=google.com; s=arc-20160816; b=kj3CNT3RNpLYveydhdonyFLYJHPhCWxs47L1G46Py+msjcKDMjC5Pv/9+gt0201Qhq VpyyzwMRIS6T+A9wyOyHRmOzaPZO9hgbet+NG8M1KW2ANzSwJbHSBgpxAKKAKifiy9QJ 4k36yJj0NktX/p/8wKYU0tQnUonNo/g2LmLnux9W6LkE2mqXP8vWq3I8A8Gp6niKTSfU 1Y+oL5tFMXp+RmLjIDVfL8Y6yi9eS5/5FUlduvIOppY6WllksNMOmWSgbF7M79EamOw7 1Km2JYyDzB1fr3TsaVx2OA4WwfPp4GkzLqmTvnoaekX9vDQVEy7waDUtM8nWIrochEHh zpNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=Osy1W1UXrB10pyCypodBWxUh9CNrVdsLdAgKLqVDe8Q=; b=wckKJ+HHIvrb8oK5pGv0fnp2qk5nujK30VBrtaMk8kfAE88AR354dfjONkNXAXpuOU ii3u9WQRq368cTxsTa4YdAube1aIoLCLs5J43lbs+LQJ31S5574QxzCdOTQlVYjE6+pu 3K4BfxJjgcGjUSuMJ1kncE3wSWXeb4rrqWp00W4R3P/MKjswNJn3VCrE0GVHFMaOiZM8 /Q5sxi9v6T0FxoA4vyX/okT4wVY1aTp4Wu8zfKsHK8OsEhjMq2iX9eTiuDxF5zKBqTJw TccaOjNO/qXwcf5yA+RDHbUgrXiDPDcr6gmzhkbrkf9wHHH5BQZFV7T4vo+Sc51vkE4t qZnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=pqKvjzXt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1si6699168pll.25.2019.06.09.03.11.29; Sun, 09 Jun 2019 03:11:45 -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; dkim=pass header.i=@yandex-team.ru header.s=default header.b=pqKvjzXt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728177AbfFIKI7 (ORCPT + 99 others); Sun, 9 Jun 2019 06:08:59 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:46672 "EHLO forwardcorp1j.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbfFIKI6 (ORCPT ); Sun, 9 Jun 2019 06:08:58 -0400 Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 461142E0AC3; Sun, 9 Jun 2019 13:08:55 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:10]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ZSzqn1Ame6-8so4F2el; Sun, 09 Jun 2019 13:08:55 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1560074935; bh=Osy1W1UXrB10pyCypodBWxUh9CNrVdsLdAgKLqVDe8Q=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=pqKvjzXtUBzAVSiDKLbZCOSS0t9ehWEZtZgDrRcDhRw3G6lZWgub6Zjydb5S4yDbp Y87xvNUR9I4izI0As/UKXeINdYRzMYShRSbiWoSq5onG4qSdj8aplmkyAH+PrEzyrS Bldyua8BJ063+uyN4eyxD7D8yN7XWfiVpmf6hmEg= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:3d25:9e27:4f75:a150]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id eNXLUmhNGx-8sga6Q9F; Sun, 09 Jun 2019 13:08:54 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH v2 2/6] proc: use down_read_killable mmap_sem for /proc/pid/smaps_rollup From: Konstantin Khlebnikov To: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Cc: Oleg Nesterov , Matthew Wilcox , Michal Hocko , Cyrill Gorcunov , Kirill Tkhai , Michal =?utf-8?q?Koutn=C3=BD?= , Al Viro , Roman Gushchin Date: Sun, 09 Jun 2019 13:08:54 +0300 Message-ID: <156007493429.3335.14666825072272692455.stgit@buzz> In-Reply-To: <156007465229.3335.10259979070641486905.stgit@buzz> References: <156007465229.3335.10259979070641486905.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not stuck forever if something wrong. Killable lock allows to cleanup stuck tasks and simplifies investigation. Signed-off-by: Konstantin Khlebnikov Reviewed-by: Roman Gushchin Reviewed-by: Cyrill Gorcunov Reviewed-by: Kirill Tkhai Acked-by: Michal Hocko --- fs/proc/task_mmu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 2bf210229daf..781879a91e3b 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -832,7 +832,10 @@ static int show_smaps_rollup(struct seq_file *m, void *v) memset(&mss, 0, sizeof(mss)); - down_read(&mm->mmap_sem); + ret = down_read_killable(&mm->mmap_sem); + if (ret) + goto out_put_mm; + hold_task_mempolicy(priv); for (vma = priv->mm->mmap; vma; vma = vma->vm_next) { @@ -849,8 +852,9 @@ static int show_smaps_rollup(struct seq_file *m, void *v) release_task_mempolicy(priv); up_read(&mm->mmap_sem); - mmput(mm); +out_put_mm: + mmput(mm); out_put_task: put_task_struct(priv->task); priv->task = NULL;