Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4117333yba; Wed, 17 Apr 2019 05:06:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHf0tNtFAUrWMZ57S7XekR5/HoOOG4msEjpi/nrOZB2jFhScqg54kmkv9ZGLftGKeRa40x X-Received: by 2002:a17:902:e109:: with SMTP id cc9mr90287522plb.148.1555502803062; Wed, 17 Apr 2019 05:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555502803; cv=none; d=google.com; s=arc-20160816; b=w/q8iz2Rt461S3dz/Ff/wOCei8K1crHxmA6qotDYe1/8GmbmUnaQ7WC04Y39kQA9kg nG4wZO40Jhok/KSrH2b92UArN7FCgtnqXV1V2rtN72UpdSxuCBKSRY/rgFh86q9eVvKe CexgKd+alWShH+yMj8dmAekTIdcB5M3sMgWPbne3d3TNSa+rwCwceuDivRlXNu4+4T93 e0QEJHZlzkrS86tYO09eZoGpej3FP7z+Mbo7IaSTz+57Van7dBsYpLVEjr6EvBPhCqOt vlImLTSEhQhA1MTC+ctMZSaBB6vg7iHVcIZJsvojtSvxIl1k53w0V6uOdb+eUWDj7XUJ Irzw== 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 :message-id:date:subject:cc:to:from; bh=JgTFmCFcOUMdDDKUPS35b9aRva/sOrdMAVuXoP/qXbw=; b=XIVge/dYoFebPYfbgfdvgLVIm4WAkVVE0eMPcOBOSD+/uCR9fu03j/lDvP7FTh8a6l TEpMLLkoqEnujMFKosYw/Ii3vRhc+Jg8m4eQ6effMUZs+QdYc5TFdqHNgWFDKYYoO8xD gHbBLlKNyRDjIaFRtUZnNqnGwUwLdNOI0r9o0TWs7DJBKeX6t8sVSuBBWtTmWGIN1hfc FCJl8u3vPTgkIipKPNHvshF79gbvc16qavNTYbh8Etn14QUMRqy+eUlP150EAGGYfY4y yXz5/Xzm0AVP8J46USBzmvrGQDK2B1urf+CiAcOfTqlo4q9VNhzBIONEs/joNDLrFl9C Yf8w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si47241769plr.69.2019.04.17.05.06.24; Wed, 17 Apr 2019 05:06:43 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732050AbfDQMEI (ORCPT + 99 others); Wed, 17 Apr 2019 08:04:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:45542 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729578AbfDQMEH (ORCPT ); Wed, 17 Apr 2019 08:04:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6C816AF8D; Wed, 17 Apr 2019 12:04:06 +0000 (UTC) From: =?UTF-8?q?Michal=20Koutn=C3=BD?= To: Andrew Morton , Mateusz Guzik , Michal Hocko Cc: Mike Rapoport , Vlastimil Babka , Geert Uytterhoeven , Arun KS , Bartosz Golaszewski , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: get_cmdline use arg_lock instead of mmap_sem Date: Wed, 17 Apr 2019 14:03:47 +0200 Message-Id: <20190417120347.15397-1-mkoutny@suse.com> X-Mailer: git-send-email 2.16.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit a3b609ef9f8b ("proc read mm's {arg,env}_{start,end} with mmap semaphore taken.") added synchronization of reading argument/environment boundaries under mmap_sem. Later commit 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct") avoided the coarse use of mmap_sem in similar situations. get_cmdline can also use arg_lock instead of mmap_sem when it reads the boundaries. Signed-off-by: Michal Koutný --- mm/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/util.c b/mm/util.c index d559bde497a9..568575cceefc 100644 --- a/mm/util.c +++ b/mm/util.c @@ -758,12 +758,12 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen) if (!mm->arg_end) goto out_mm; /* Shh! No looking before we're done */ - down_read(&mm->mmap_sem); + spin_lock(&mm->arg_lock); arg_start = mm->arg_start; arg_end = mm->arg_end; env_start = mm->env_start; env_end = mm->env_end; - up_read(&mm->mmap_sem); + spin_unlock(&mm->arg_lock); len = arg_end - arg_start; -- 2.16.4