Received: by 10.213.65.68 with SMTP id h4csp383776imn; Tue, 27 Mar 2018 00:38:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ww0RDPv/THQJ7GTV1sNyPru8QeqwAp73pge8K3CrrN/1r08ZS2U1tLhu5pM1o1A1RnCJ2 X-Received: by 2002:a17:902:3e5:: with SMTP id d92-v6mr9413795pld.104.1522136333714; Tue, 27 Mar 2018 00:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522136333; cv=none; d=google.com; s=arc-20160816; b=BsQEGe/3RPBYi9MhWaeiwzbtK+gJIqhU2fQg3dP7LjLeMhtNj3ydjfwK8ta75Q+c+b 5zLJa9d938/2anroIDNKdkxPWICqeEv/oYBPG6VyfElqd0x1vsDrmua9PBJiQ05dQkob mzZz4blWdEiQWHufY6jn9qwQib9ilMk0t53D+IEuyDzRWFro3qGllNAf760rY3DN5+Ys cWzjmswHUmWPyjnsBp6vJgF/L4+s1YEoq71GsXUyVKW4yNe3iXMd2M1RFtztA6H78VVX ED1vq1bK7zVIljWXTXlDJtqfbQx6a90Dl6li6IJPDVAHpPcg8XaV2DpWAOjGceQVbmnJ 5eIw== 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=+8kOhufYUc5ilZDf7gJR42vrAgoyV6d0lf76rypqSbM=; b=UM4FJbSnECEwVVCqD3zAgS5GAScMC3oa8hka3qS6vr/0zQGHgkVvFTFwL1aMGL1SWV wbDOx/mhxSV5qq07iLeUg/kUua0/w0wkRSvryJcS05BD/cy+JO/OuOc3bQClShESAQk4 buhx7cvvTOMjTPrTna9ddNSl5D75iTezevHqvPayQ3TBoIHLJ12GqFkpzORRNL5L9TCK b8ljrPxy9UHn/1S4ogoiU2vhkj8ao5cxGD7RJo3tJca8Zl8ExwJhGs0M+/Xgz55Ya2S9 hFZ0uRQiPNhrF84VptF14mg+pD1Au9Nt8Lf3M2DQJ8z3VSGfxQDmJG9D++Gvi/0T0sb7 hI0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LOL7GCBk; 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 67-v6si693604pla.612.2018.03.27.00.38.39; Tue, 27 Mar 2018 00:38:53 -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=LOL7GCBk; 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 S1751805AbeC0HhJ (ORCPT + 99 others); Tue, 27 Mar 2018 03:37:09 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:39888 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059AbeC0HhH (ORCPT ); Tue, 27 Mar 2018 03:37:07 -0400 Received: by mail-lf0-f65.google.com with SMTP id p142-v6so31839991lfd.6 for ; Tue, 27 Mar 2018 00:37:06 -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=+8kOhufYUc5ilZDf7gJR42vrAgoyV6d0lf76rypqSbM=; b=LOL7GCBkGTSOX66TSEEHx/pwv+fQ6OA7TQfaEJwvGh8dxjjZm1v25spiHvfRcbvdBg FQaoWDI69ExBMDRexuM6SJlB0Ggon0b6ViZlwsW2Vsbjo8tqi1uhgSdizuPnJ7h3CgiQ Em5mdUF54koDAZDiSsj7UTJ61vlW3LLPiMmBdVhHuBia8RxSQUg/3NVy5kF4+BbcMV2I 5k5XXawUbZCY2tSpUHdqQQJD2WXJAl9ZAanpW1uxdimTwKYCngpMcPx6JHBWCKKTbiu7 4kAZBLSECeAWD3z4m+JDNA4W2chsdK4cZmWnLbXRq32TP58YCywkpg91kZrR/hslJ+q4 ut9Q== 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=+8kOhufYUc5ilZDf7gJR42vrAgoyV6d0lf76rypqSbM=; b=fF3UOtnHH4pumT6rOjVn07LPFM4scQaADEqYFanJ/6MnCSY32Et9EtHvHQlDULecCe nE6Uf4LWs0OVbfER0ybLIs5nzL0HcIr/9UXHlFhXLRg2oOCE5mx0/jSzGxulyWGfge8w 1jeGu1ewoMAoUX00+s+4capHkbW/oXv5S2JxwpCw20eiP8fFtym9A6A2KIyd+3UxcA5M ILvKtGO7pF22O+Aoon3TY3QTFVRW5Pfh+ArCcLcGTN7tZ3PdNKZMJmt1ROifY744Llt7 4wcMfc8Bp8nWo7lDkDrzRm0i4a3VtLkjTVQ51YbH9uJsoQaPLcnNw6RhcViT18XgfNeq WPww== X-Gm-Message-State: AElRT7ETNjvDEkJpFpMYKXoR8IEXguvmvjK4hPXjkHMC5RoG6C/YMHNE lDCqkEnEmUoKoUsN8N/Rb7A= X-Received: by 10.46.16.1 with SMTP id j1mr11003485lje.102.1522136226226; Tue, 27 Mar 2018 00:37:06 -0700 (PDT) Received: from uranus.localdomain ([5.18.102.224]) by smtp.gmail.com with ESMTPSA id s1sm109055lji.92.2018.03.27.00.37.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Mar 2018 00:37:05 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id E74EF460AA4; Tue, 27 Mar 2018 10:37:04 +0300 (MSK) Date: Tue, 27 Mar 2018 10:37:04 +0300 From: Cyrill Gorcunov To: Tetsuo Handa Cc: willy@infradead.org, yang.shi@linux.alibaba.com, 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: <20180327073704.GH2236@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> <20180326212944.GF2236@uranus> <201803270700.IJB35465.HJQFSFMVLFOtOO@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201803270700.IJB35465.HJQFSFMVLFOtOO@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 07:00:56AM +0900, Tetsuo Handa wrote: > > > 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. > > But this is userspace visible API and thus we cannot change. Hi! We could deplrecate this API call for a couple of releases and then if nobody complain we could rip it off completely. There should not be many users I think, didn't heard that someone except criu used it ever. > > > 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. > > > > You are not missing my point. What I thought is > > +retry: > - down_read(&mm->mmap_sem); > 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); > > - BUG_ON(arg_start > arg_end); > - BUG_ON(env_start > env_end); > + if (unlikely(arg_start > arg_end || env_start > env_end)) { > + cond_resched(); > + goto retry; > + } > > for reading these fields. I fear such contentional cycles are acceptable if only they are guaranteed to finish eventually. Which doesn't look so in the code above. Cyrill