From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932745AbdLOW16 (ORCPT ); Fri, 15 Dec 2017 17:27:58 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:58376 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757102AbdLOW1y (ORCPT ); Fri, 15 Dec 2017 17:27:54 -0500 Date: Fri, 15 Dec 2017 14:27:52 -0800 From: Andrew Morton To: Michal Hocko Cc: "Huang, Ying" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Minchan Kim , Johannes Weiner , Tim Chen , Shaohua Li , Mel Gorman , =?ISO-8859-1?Q?J=E9r=F4me?= Glisse , Andrea Arcangeli , David Rientjes , Rik van Riel , Jan Kara , Dave Jiang , Aaron Lu Subject: Re: [PATCH -mm -V2] mm, swap: Fix race between swapoff and some swap operations Message-Id: <20171215142752.8680ebf607aeae94c32760b5@linux-foundation.org> In-Reply-To: <20171215100443.GX16951@dhcp22.suse.cz> References: <20171214133832.11266-1-ying.huang@intel.com> <20171214151718.GS16951@dhcp22.suse.cz> <20171214124246.ceebc9c955bd32601c01a28b@linux-foundation.org> <20171215100443.GX16951@dhcp22.suse.cz> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Dec 2017 11:04:43 +0100 Michal Hocko wrote: > On Thu 14-12-17 12:42:46, Andrew Morton wrote: > > On Thu, 14 Dec 2017 16:17:18 +0100 Michal Hocko wrote: > > > > > > as fast as possible, SRCU instead of reference count is used to > > > > implement get/put_swap_device(). From get_swap_device() to > > > > put_swap_device(), the reader side of SRCU is locked, so > > > > synchronize_srcu() in swapoff() will wait until put_swap_device() is > > > > called. > > > > > > It is quite unfortunate to pull SRCU as a dependency to the core kernel. > > > Different attempts to do this have failed in the past. This one is > > > slightly different though because I would suspect that those tiny > > > systems do not configure swap. But who knows, maybe they do. > > > > > > Anyway, if you are worried about performance then I would expect some > > > numbers to back that worry. So why don't simply start with simpler > > > ref count based and then optimize it later based on some actual numbers. > > > Btw. have you considered pcp refcount framework. I would suspect that > > > this would give you close to SRCU performance. > > > > Or use stop_kernel() ;) > > well, stop_kernel is a _huge_ hammer. But it's very simple and requires zero code changes on the fast path. This makes it appropriate for swapoff! > I think we can do much better > without a large complexity. A simple ref counting (or pcp refcounting if > the former has measurable complexity) should do just fine. I'd like to be able to compare the implementations ;)