Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2075639ybi; Sun, 9 Jun 2019 03:10:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7VwbqdeR4t84HPUmmjFqf9n3Us8HX2+I7U0HV1wHQDLzznnh9sTsJX/VT20hRxsM6Abvj X-Received: by 2002:a17:902:ac1:: with SMTP id 59mr3717233plp.168.1560075026028; Sun, 09 Jun 2019 03:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560075026; cv=none; d=google.com; s=arc-20160816; b=u22punl35fykkpCl2wHpix3TUw8/8EUnJCMd+M8e+y6LHwtvFjcNH9rUhgt6BYqHR1 K80wja1a81OUKDVUe2virRscbKDAe1FGkdSUTgPhzcuvXd0gQjx6sPINwI6nZ9vsZnkG EC5sQ3+jwmSkGxyQh0M8nfAA1cx0lYMUlz3egQG3sWIpH0zYfbWvB2+jRdJexN/oevmW JBo4gAEGabtP/S8SbR104Bls9LpyoG/5z+ieJ31kIefFAdpNKiaqPV2/SrRoPnW1X8Ey CiUTug2XBVKUqPVxKyJaKnUmuAKDAtTnLjFutlTLyhk0/06MKJYaT281S6BFZ7sMakO7 omkg== 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=3rk+4uRwl46CAyP7ka3QhboNqPwEZHBXTQqkcXWKDZU=; b=VzM0rL521KG3u7/hn+VL2P7w7141aMEfqc6JQvvegXUQhmvfrr6jav/NKhwK3wI4iZ OdILE3UUxD372czfkFRiauHyZvxi8PAwYmaW73Z45ytsumsdDBDeJkjSlIK38IpnNGcu osvwzpxGAJn5tcSPWcxRB+qhOQ7zzqJHHaaK2EO5NfD7BVi2Mymy6V+1FG2M5TTqXGpa rHdfic+D4Bjzwvpy5OK+o16hMSgFS78hmiBVfK8D0sW9efLBcPjhvVzpSz0CU6xwUAjg J/BTrY0neJadrVmNYgA28Z/yVMKMMXyyQ1fLZhe1K2PNoqvx/QC53jGpqs/FVJ/fTC9c iRdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=HEBN1BfE; 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 o11si1215830pjb.30.2019.06.09.03.10.10; Sun, 09 Jun 2019 03:10:26 -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=HEBN1BfE; 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 S1728217AbfFIKJD (ORCPT + 99 others); Sun, 9 Jun 2019 06:09:03 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:46698 "EHLO forwardcorp1j.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728149AbfFIKJA (ORCPT ); Sun, 9 Jun 2019 06:09:00 -0400 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 265F52E097B; Sun, 9 Jun 2019 13:08:57 +0300 (MSK) Received: from smtpcorp1o.mail.yandex.net (smtpcorp1o.mail.yandex.net [2a02:6b8:0:1a2d::30]) by mxbackcorp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id pNBtwZTYyg-8udqp0pt; Sun, 09 Jun 2019 13:08:57 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1560074937; bh=3rk+4uRwl46CAyP7ka3QhboNqPwEZHBXTQqkcXWKDZU=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=HEBN1BfECtA+NWOl1NyhYjybz8lV9L5DriON81fOTee7qLzo9B1x324RjmVk79R1d EPwmvCOgjHYCRKWT83RsO0l/Q9io6+Tangbs3bDwNXlFGnRXGUalmBWJ7ENrOSa5Rs E5y5f08BToJC0UDl/kAKm5SjyMhHRX/j+Ms+1QrE= Authentication-Results: mxbackcorp2j.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 smtpcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Qx30l6oFjQ-8uYGIqxH; Sun, 09 Jun 2019 13:08:56 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH v2 3/6] proc: use down_read_killable mmap_sem for /proc/pid/pagemap 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:56 +0300 Message-ID: <156007493638.3335.4872164955523928492.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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 781879a91e3b..78bed6adc62d 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1547,7 +1547,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, /* overflow ? */ if (end < start_vaddr || end > end_vaddr) end = end_vaddr; - down_read(&mm->mmap_sem); + ret = down_read_killable(&mm->mmap_sem); + if (ret) + goto out_free; ret = walk_page_range(start_vaddr, end, &pagemap_walk); up_read(&mm->mmap_sem); start_vaddr = end;