From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754754Ab2GRWtN (ORCPT ); Wed, 18 Jul 2012 18:49:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44482 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751491Ab2GRWtK (ORCPT ); Wed, 18 Jul 2012 18:49:10 -0400 Date: Wed, 18 Jul 2012 15:49:08 -0700 From: Andrew Morton To: Rafael Aquini Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Rusty Russell , "Michael S. Tsirkin" , Rik van Riel , Mel Gorman , Andi Kleen , Konrad Rzeszutek Wilk , Minchan Kim , Rafael Aquini Subject: Re: [PATCH v4 2/3] virtio_balloon: introduce migration primitives to balloon pages Message-Id: <20120718154908.14704344.akpm@linux-foundation.org> In-Reply-To: <050e06731e0489867ed804387509e36d072507ec.1342485774.git.aquini@redhat.com> References: <050e06731e0489867ed804387509e36d072507ec.1342485774.git.aquini@redhat.com> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; 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 Tue, 17 Jul 2012 13:50:42 -0300 Rafael Aquini wrote: > Besides making balloon pages movable at allocation time and introducing > the necessary primitives to perform balloon page migration/compaction, > this patch also introduces the following locking scheme to provide the > proper synchronization and protection for struct virtio_balloon elements > against concurrent accesses due to parallel operations introduced by > memory compaction / page migration. > - balloon_lock (mutex) : synchronizes the access demand to elements of > struct virtio_balloon and its queue operations; > - pages_lock (spinlock): special protection to balloon pages list against > concurrent list handling operations; > > ... > > + balloon_mapping->a_ops = &virtio_balloon_aops; > + balloon_mapping->backing_dev_info = (void *)vb; hoo boy. We're making page->mapping->backing_dev_info point at a struct which does not have type `struct backing_dev_info'. And then we are exposing that page to core MM functions. So we're hoping that core MM will never walk down page->mapping->backing_dev_info and explode. That's nasty, hacky and fragile.