From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933221AbbCPQhY (ORCPT ); Mon, 16 Mar 2015 12:37:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43837 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933088AbbCPQhV (ORCPT ); Mon, 16 Mar 2015 12:37:21 -0400 Date: Mon, 16 Mar 2015 17:35:21 +0100 From: Oleg Nesterov To: Konstantin Khlebnikov Cc: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org, Davidlohr Bueso , Al Viro Subject: Re: [PATCH] mm: rcu-protected get_mm_exe_file() Message-ID: <20150316163521.GA9306@redhat.com> References: <20150316131257.32340.36600.stgit@buzz> <20150316140720.GA1859@redhat.com> <550701BE.40100@yandex-team.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <550701BE.40100@yandex-team.ru> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/16, Konstantin Khlebnikov wrote: > > On 16.03.2015 17:07, Oleg Nesterov wrote: >> I mean, I think we can do another cleanup on top of this change. >> >> 1. set_mm_exe_file() should be called by exit/exec only, so >> it should use >> >> rcu_dereference_protected(mm->exe_file, >> atomic_read(&mm->mm_users) <= 1); >> >> 2. prctl() should not use it, it can do >> >> get_file(new_exe); >> old_exe = xchg(&mm->exe_file); >> if (old_exe) >> fput(old_exe); > > I think smp_mb() is required before xchg() or > probably this stuff should be hidden inside yet another magic RCU macro > ( with two screens of comments =) Not really, xchg() implies mb's on both sides. As any other atomic operation which returns the result. (And in fact we do not even need rcu_assign_pointer() in set_mm_exe_file(), get_mm_exe_file() could do READ_ONCE() + inc_not_zero(). But this is off- topic, and of course rcu_* helpers look better) Oleg.