From patchwork Mon Jun 17 09:17:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 251790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C96272C0174 for ; Mon, 17 Jun 2013 19:17:45 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755817Ab3FQJRo (ORCPT ); Mon, 17 Jun 2013 05:17:44 -0400 Received: from mail-ie0-f172.google.com ([209.85.223.172]:54844 "EHLO mail-ie0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750986Ab3FQJRn (ORCPT ); Mon, 17 Jun 2013 05:17:43 -0400 Received: by mail-ie0-f172.google.com with SMTP id 16so6423636iea.3 for ; Mon, 17 Jun 2013 02:17:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=uHAYu1cSLWAhYBHQMBvpxLajLox3FdeBsscL6pm3MEU=; b=TYnT9hKHgfvFefEuSWlc4Ui5Ze45v2u0G+2cyOJGvX/SboZIndDNG35KvvmPM6gaos hjMH7lz/h+2LZ5TjhhdbRgNFxXTrb4ZhgCjO0HChqh3t+fF4OecrY6V8TFlO71ZPVo2S oHBbqnPiSqREzG42d09cqjsW8RJOQClInhagTIosdwOecAZ423rDntweLuvvC4+t0m2j jiA7uOzXK9o1mNUZ+UWnzouho4/RUpQQwqn7ujYmiJ+nlPMVso1DbbaGhrR9k5PwK/J8 e5ytqbamHCgmf86d7JYe6bEs6JSbdB+Z4dyaQQ3Ya9ESz7CNr3EWCXOrwiJOJjc17/LI sUKw== X-Received: by 10.50.178.138 with SMTP id cy10mr4395448igc.92.1371460663037; Mon, 17 Jun 2013 02:17:43 -0700 (PDT) Received: from aik.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPSA id nm17sm16235325igb.5.2013.06.17.02.17.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 17 Jun 2013 02:17:42 -0700 (PDT) Message-ID: <51BED42F.9000507@ozlabs.ru> Date: Mon, 17 Jun 2013 19:17:35 +1000 From: Alexey Kardashevskiy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: Benjamin Herrenschmidt CC: linuxppc-dev@lists.ozlabs.org, David Gibson , Alexander Graf , Paul Mackerras , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kvm-ppc@vger.kernel.org, "linux-mm@kvack.org" Subject: Re: [PATCH 2/4] powerpc: Prepare to support kernel handling of IOMMU map/unmap References: <1370412673-1345-1-git-send-email-aik@ozlabs.ru> <1370412673-1345-3-git-send-email-aik@ozlabs.ru> <1371356818.21896.114.camel@pasglop> In-Reply-To: <1371356818.21896.114.camel@pasglop> X-Gm-Message-State: ALoCoQlTjdf4fo7BJWBsqMiQNYykaLC2sfqGQbWRccu8fGpfpUvkbDBXhRBwrzmZ+izoDMaPBdaF Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org On 06/16/2013 02:26 PM, Benjamin Herrenschmidt wrote: >> +#if defined(CONFIG_SPARSEMEM_VMEMMAP) || defined(CONFIG_FLATMEM) >> +int realmode_get_page(struct page *page) >> +{ >> + if (PageCompound(page)) >> + return -EAGAIN; >> + >> + get_page(page); >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(realmode_get_page); >> + >> +int realmode_put_page(struct page *page) >> +{ >> + if (PageCompound(page)) >> + return -EAGAIN; >> + >> + if (!atomic_add_unless(&page->_count, -1, 1)) >> + return -EAGAIN; >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(realmode_put_page); >> +#endif > > Several worries here, mostly that if the generic code ever changes > (something gets added to get_page() that makes it no-longer safe for use > in real mode for example, or some other condition gets added to > put_page()), we go out of sync and potentially end up with very hard and > very subtle bugs. > > It might be worth making sure that: > > - This is reviewed by some generic VM people (and make sure they > understand why we need to do that) > > - A comment is added to get_page() and put_page() to make sure that if > they are changed in any way, dbl check the impact on our > realmode_get_page() (or "ping" us to make sure things are still ok). After changing get_page() to get_page_unless_zero(), the get_page API I use is: get_page_unless_zero() - basically atomic_inc_not_zero() atomic_add_unless() - just operated with the counter PageCompound() - check if it is a huge page. No usage of get_page or put_page. If any of those changes, I would expect it to hit us immediately, no? So it may only make sense to add a comment to PageCompound(). But the comment says "PageCompound is generally not used in hot code paths", and our path is hot. Heh. So? diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 6d53675..c70a654 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -329,7 +329,8 @@ static inline void set_page_writeback(struct page *page) * System with lots of page flags available. This allows separate * flags for PageHead() and PageTail() checks of compound pages so that bit * tests can be used in performance sensitive paths. PageCompound is - * generally not used in hot code paths. + * generally not used in hot code paths except arch/powerpc/mm/init_64.c + * which uses it to detect huge pages and avoid handling those in real mode. */ __PAGEFLAG(Head, head) CLEARPAGEFLAG(Head, head) __PAGEFLAG(Tail, tail)