From patchwork Tue Jun 13 10:28:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 104379 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp393081obh; Tue, 13 Jun 2017 03:29:29 -0700 (PDT) X-Received: by 10.98.147.142 with SMTP id r14mr32647835pfk.168.1497349769670; Tue, 13 Jun 2017 03:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497349769; cv=none; d=google.com; s=arc-20160816; b=Zu1GTDpDti1L78a5wR1vJN0Mg5QcFVAK8yg6y0jtkH4JhS9uCuLeA99HTK5DS2YMUL 4jBgf44aA0qow0k/yEDJRYAQFtA6u6x9fV8ABwE6PV72Awp9BRuA5+1+bEoekGfcjGME lSeO5LjUI3kc+BnvHHGcQjlLttLfSRFPOqS9L2wb2vvfazzMZT6QdUV5c/l6kckBDhI/ BWz00QD8LpmspWr+up8EZU8ynvBuLUc4uOHG95Nwd2EwRXO6NdlF5+8xLNPiwGpz+nwK Wy9G9YtT9Fyo4Uuutmxz000MDRACHBLkDX2XmyFp6VRAr9cgDAkTtGhKVcB5Vjm01Ypi mEOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=oGHPRLFjvlNfehM0CItXKBzVfPSp1g4bFNzfKkIFhFE=; b=iXiznDOUjpcztn+XeZPm+4dxi2b4VQv+sttzcDvHo4FC5uwrwHdDGa5cPBE4JfeHCi kP9SFEawgPK5nke9TBE0Bc9URMTmIkphbWqQ7d3E7bcuBngrl0TsWawfdIBsVag+0YJZ FVR9CI+AN38YWabLJPG216lOOgVi4O+pBc4vqn56bzfkhGmxQ+M+WAA9w6nvnkAbT/62 doMkye7z1koN4CuF1bNLcZsnhpczTG/RfwXco6K2jNYL61DXf2Ic6yNPheTWyh9BTl1D 8m8Gt6eXut5ceYGiLiwWcEav3tJrudeD2P63JLM7/hopXT8MkojjXEXmP21/7FmDGZsu TezA== 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 l2si9010226pfg.217.2017.06.13.03.29.29; Tue, 13 Jun 2017 03:29:29 -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 S1753099AbdFMK3R (ORCPT + 25 others); Tue, 13 Jun 2017 06:29:17 -0400 Received: from foss.arm.com ([217.140.101.70]:46154 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752156AbdFMK2f (ORCPT ); Tue, 13 Jun 2017 06:28:35 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F3EC615B2; Tue, 13 Jun 2017 03:28:34 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C690A3F889; Tue, 13 Jun 2017 03:28:34 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id D6A1C1AE30E8; Tue, 13 Jun 2017 11:28:44 +0100 (BST) From: Will Deacon To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: mark.rutland@arm.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, Punit.Agrawal@arm.com, mgorman@suse.de, steve.capper@arm.com, vbabka@suse.cz, Will Deacon Subject: [PATCH v2 2/3] mm/page_ref: Ensure page_ref_unfreeze is ordered against prior accesses Date: Tue, 13 Jun 2017 11:28:41 +0100 Message-Id: <1497349722-6731-3-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1497349722-6731-1-git-send-email-will.deacon@arm.com> References: <1497349722-6731-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org page_ref_freeze and page_ref_unfreeze are designed to be used as a pair, wrapping a critical section where struct pages can be modified without having to worry about consistency for a concurrent fast-GUP. Whilst page_ref_freeze has full barrier semantics due to its use of atomic_cmpxchg, page_ref_unfreeze is implemented using atomic_set, which doesn't provide any barrier semantics and allows the operation to be reordered with respect to page modifications in the critical section. This patch ensures that page_ref_unfreeze is ordered after any critical section updates, by invoking smp_mb() prior to the atomic_set. Cc: "Kirill A. Shutemov" Acked-by: Steve Capper Signed-off-by: Will Deacon --- include/linux/page_ref.h | 1 + 1 file changed, 1 insertion(+) -- 2.1.4 Acked-by: Kirill A. Shutemov diff --git a/include/linux/page_ref.h b/include/linux/page_ref.h index 610e13271918..1fd71733aa68 100644 --- a/include/linux/page_ref.h +++ b/include/linux/page_ref.h @@ -174,6 +174,7 @@ static inline void page_ref_unfreeze(struct page *page, int count) VM_BUG_ON_PAGE(page_count(page) != 0, page); VM_BUG_ON(count == 0); + smp_mb(); atomic_set(&page->_refcount, count); if (page_ref_tracepoint_active(__tracepoint_page_ref_unfreeze)) __page_ref_unfreeze(page, count);