Received: by 10.213.65.68 with SMTP id h4csp36678imn; Mon, 26 Mar 2018 14:31:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELuSAo6d33V2pLxDpGsJFfKzAp3qEeWhwcjH6FnpNEsPmI/ROwwatfXOHoCOd9wHsk8XpnqT X-Received: by 10.99.127.27 with SMTP id a27mr29001005pgd.18.1522099862145; Mon, 26 Mar 2018 14:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522099862; cv=none; d=google.com; s=arc-20160816; b=qH+l/zhTU7IinknRnDxqYOpMhRdxNXeMoykBXFJXBCmW0CclP3i3wAfuht7fTSvOiL g7s6YM078pqWa4fi/7SvUUdU0HuBIjz4I1+C4cmluLHCnclSNPgs8YMZMWzHb8Q5INWc LZB/0EDniJTrPSA/PYYkjMMl8XOvwhvOwCQytfCUXty0adjf5jZisfrR57ZFqaFKWkM+ lNTrqesJ/H45i1ZFhvzoklTeEn+DxHtqUOCxMMnVJ7BJsw1qYOIA5XRkcld4cvtglDzs +S0FDN9QMS/TX/MXL9ElXvn+gs4SMJc/Bvl922jj7q9VN7HqmhfLyp6qThGMBrWpjPFO qDqQ== 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:dkim-signature:arc-authentication-results; bh=7PNp++FCI6zPwbSGr+Yc0EcVfbiWOqXzmnt+DLWyXkw=; b=VxeRIX08MyuwS6JQqIK6DOTBi+NFmIJEa3hgWc1u0GLJTkIwK804FfzySF//YXzLUN 1gcsoFto/t7N4ydqmJBE7+rVWITMoYG3Qc7BTtcvxn2e/2kJQEBnBGrGlFW1mklh90WZ eM/Hdd1TbqVCdq51YRcDEjAzMgrOxeswQzOrWPqBbfg5iHn5a5XAYvM+vCWuv12Gkwzi t7HTguWLix64I85twbqA+3Fc7njk7LxwX7lce45YKYCUwfDyJRx/wXHWofPu3GtqzLJk 04ZTQcYufH58qugPORJHsiLiYRLJqkfIEqF9BIpCDbB/4Rb5GkI293dlKPwu86YY8iEh o24g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P/yBwtU/; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y38-v6si2360310plh.476.2018.03.26.14.30.46; Mon, 26 Mar 2018 14:31:02 -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=@gmail.com header.s=20161025 header.b=P/yBwtU/; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752066AbeCZV3s (ORCPT + 99 others); Mon, 26 Mar 2018 17:29:48 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:38671 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730AbeCZV3r (ORCPT ); Mon, 26 Mar 2018 17:29:47 -0400 Received: by mail-lf0-f67.google.com with SMTP id u3-v6so9369348lff.5 for ; Mon, 26 Mar 2018 14:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7PNp++FCI6zPwbSGr+Yc0EcVfbiWOqXzmnt+DLWyXkw=; b=P/yBwtU/bBkbg8YVAL4Djgyuo7n6DOHKsKUZ27h5JatJpOuZYHjbaOxNH87Nua0LZM DL38MqKQht49ngtQFH2zeYaWRom0xJf0KY2hjJqJ35s4yw62tVrVMeoata8cJzWrG73n SP41m2nw5uhddFRMAWkhToWqCwLEtQzznZu5qIQh/JwX8b2d23nE/aKXQekTtcb2Ukdx nW1ZoXz3+0ZuGXKXVymHex7ZD9tCrTa27WYhRmhVuWMPpY6LJ5LysdGQeA4+o8uLqrR2 vgvByjjwgeO5DxcnzYenHbDrVcQuFl06X7jAmu7Lkrtg0h0bAGuLBDmlxgqK9Rt8/QP7 RNuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7PNp++FCI6zPwbSGr+Yc0EcVfbiWOqXzmnt+DLWyXkw=; b=AHIJY9PVq/fmST52Hi2SnPLazlsXCpCdRAndniMQghaMSkLnwJT5zXY/DoYP/fzkci TswvxRR85K+LUq5POy6MLpUlJBY5fSkTBUl8oWikHWa5tBVlnZYwWF6ZSOgsPiUAXNYS fBHuU7lufnfABKW5+lo3xVRC7KaluBoPBiWSguvHwcxDu2igr5F/m0/DV5fiHtO6Ek0l 8S6gr1T0143LJKoThf7z3jFpaNerGw82Ko1oWVkYfzBGZULzPejkQnLK+p/oXi2abK+v 9T2D1bkxAkJGrfI+3OXGcyV0VVQSJ8jafrpCzN76rl4yo2vBboVFIkmmtuNoNtBrpIHB gaGQ== X-Gm-Message-State: AElRT7Henl8JhdZz7ytexuOgP37xVZUfi0ozDIudRUsWSY47Uznh2mXv Ho6gr8jB1EDrPQISb+qXjbs= X-Received: by 10.46.4.149 with SMTP id a21mr28757951ljf.138.1522099785916; Mon, 26 Mar 2018 14:29:45 -0700 (PDT) Received: from uranus.localdomain ([5.18.102.224]) by smtp.gmail.com with ESMTPSA id 63-v6sm4005202lfr.61.2018.03.26.14.29.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Mar 2018 14:29:44 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id 92049460893; Tue, 27 Mar 2018 00:29:44 +0300 (MSK) Date: Tue, 27 Mar 2018 00:29:44 +0300 From: Cyrill Gorcunov To: Tetsuo Handa Cc: Matthew Wilcox , Yang Shi , adobriyan@gmail.com, mhocko@kernel.org, mguzik@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [v2 PATCH] mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct Message-ID: <20180326212944.GF2236@uranus> References: <1522088439-105930-1-git-send-email-yang.shi@linux.alibaba.com> <20180326183725.GB27373@bombadil.infradead.org> <20180326192132.GE2236@uranus> <0bfa8943-a2fe-b0ab-99a2-347094a2bcec@i-love.sakura.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0bfa8943-a2fe-b0ab-99a2-347094a2bcec@i-love.sakura.ne.jp> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 27, 2018 at 06:10:09AM +0900, Tetsuo Handa wrote: > On 2018/03/27 4:21, Cyrill Gorcunov wrote: > > That said I think using read-lock here would be a bug. > > If I understand correctly, the caller can't set both fields atomically, for > prctl() does not receive both fields at one call. > > prctl(PR_SET_MM, PR_SET_MM_ARG_START xor PR_SET_MM_ARG_END xor PR_SET_MM_ENV_START xor PR_SET_MM_ENV_END, new value, 0, 0); > True, but the key moment is that two/three/four system calls can run simultaneously. And while previously they are ordered by "write", with read lock they are completely unordered and this is really worries me. To be fair I would prefer to drop this old per-field interface completely. This per-field interface was rather an ugly solution from my side. > Then, I wonder whether reading arg_start|end and env_start|end atomically makes > sense. Just retry reading if arg_start > env_end or env_start > env_end is fine? Tetsuo, let me re-read this code tomorrow, maybe I miss something obvious.