Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756021Ab3HMHpc (ORCPT ); Tue, 13 Aug 2013 03:45:32 -0400 Received: from lgeamrelo01.lge.com ([156.147.1.125]:42687 "EHLO LGEAMRELO01.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752223Ab3HMHpb (ORCPT ); Tue, 13 Aug 2013 03:45:31 -0400 X-AuditID: 9c93017d-b7cdfae0000026c0-98-5209e419b200 Date: Tue, 13 Aug 2013 16:45:44 +0900 From: Joonsoo Kim To: Davidlohr Bueso Cc: Andrew Morton , Rik van Riel , Mel Gorman , Michal Hocko , "Aneesh Kumar K.V" , KAMEZAWA Hiroyuki , Hugh Dickins , Davidlohr Bueso , David Gibson , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wanpeng Li , Naoya Horiguchi , Hillf Danton Subject: Re: [PATCH v2 09/20] mm, hugetlb: protect region tracking via newly introduced resv_map lock Message-ID: <20130813074544.GA22918@lge.com> References: <1376040398-11212-1-git-send-email-iamjoonsoo.kim@lge.com> <1376040398-11212-10-git-send-email-iamjoonsoo.kim@lge.com> <1376344985.13247.16.camel@buesod1.americas.hpqcorp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1376344985.13247.16.camel@buesod1.americas.hpqcorp.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1251 Lines: 42 > > @@ -202,15 +199,27 @@ static long region_chg(struct resv_map *resv, long f, long t) > > * Subtle, allocate a new region at the position but make it zero > > * size such that we can guarantee to record the reservation. */ > > if (&rg->link == head || t < rg->from) { > > - nrg = kmalloc(sizeof(*nrg), GFP_KERNEL); > > - if (!nrg) > > - return -ENOMEM; > > + if (!nrg) { > > + nrg = kmalloc(sizeof(*nrg), GFP_NOWAIT); > > + if (!nrg) { > > + spin_unlock(&resv->lock); > > + nrg = kmalloc(sizeof(*nrg), GFP_KERNEL); > > + if (!nrg) { > > + chg = -ENOMEM; > > + goto out; > > Just return -ENOMEM here. Okay. It looks better! > > > + } > > + goto retry; > > + } > > + } > > + > > You seem to be right, at least in my workloads, the hold times for the > region lock is quite small, so a spinlock is better than a sleeping > lock. > > That said, this code is quite messy, but I cannot think of a > better/cleaner approach right now. Okay. Thanks for review! -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/