Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp404496imm; Thu, 21 Jun 2018 21:39:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLTyokoUn6LMa65UREjXvukQLxa7nzmAjLhn//rEiJPrvfbf9DvDtVWJdFetg9em2pFdnYn X-Received: by 2002:a17:902:a518:: with SMTP id s24-v6mr29845plq.144.1529642358101; Thu, 21 Jun 2018 21:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529642358; cv=none; d=google.com; s=arc-20160816; b=qt4tUBzl+rc0Q8p4AM4JA9ESWkfpFViXADYJunm9tmzeF28g6OfcZebWyDr7wcP14T Bf/s0isQbl5icKix0q58oOjYj/zjejCH8jz7s1xYbNhuscZZ1Pjg8pMUimgQr7syXFE9 qhYBuVhdXG2j6DHEX9O1hsdsQFXX7ISU8beBx14n0pSZfOoAdz2vqVoT9TaYASncRDfD rEteBjGbYE7C4c/G8BYLwdw2k6I0zmrMyK4LoJSbr4FEjRFGlwTRyJNdLD538xuuZY0A FctPb9ejDZ97zEypgUDwmNOe9XnKvj3XW1JR2j0Yc2J1YF5fImknosrcpXpSWD9Fjy04 tUxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=8jlqwEhr+uJtI6jXLb2tvA9oJAs97gbe2iCPBPrrfS0=; b=cbS2y2IGTw3GYbDCPRlGmqIzKzfpxkqXjzm65LhzP8jO0wjljwvrczPC9gY31RX8Le zCeLiTVo3XiP0RiN7Ex2zDUvGUV2T6iBZoeOJzy+DXp4U7ISgfd/Ca9LYfm5dEtJx1sk NKh8TvKYdhq6TPy4P+w0NqgJWgWV/x6a/LwaZYTz1RraKVUioD/cp2TKUJiNaV/9fE0+ yv+4aBgx5pYktGoTZ7P94c3Ej+lLVuePqDOaTc/ILBzERfe05UBHYnjRhHdRtMzQ1117 p5JTJTkzD1sUrjEM6znIwJ7eEGbZ+/CUrLHP7oGim73uOBoY3NYL2P3kEPhjnWXBNUsf uAvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=iXgxgxCQ; 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 l13-v6si6134509pff.261.2018.06.21.21.39.02; Thu, 21 Jun 2018 21:39:18 -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; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=iXgxgxCQ; 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 S1751099AbeFVEiT (ORCPT + 99 others); Fri, 22 Jun 2018 00:38:19 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:33052 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750779AbeFVEiS (ORCPT ); Fri, 22 Jun 2018 00:38:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pI3/H+VocM9pXxC4tlm4I7EA74TtdEIYh6Pnm1Ll934=; b=iXgxgxCQy1OJ14oyiNOkeYS1X HLAMnVaFJEkfOpy2MlgWLkxS/wtgmKjb9Fk8CyVfqekMuv4hIqhdY8dlLwuhNdenQncgsA+KcbTf/ vPBB9ZThudy7enIX1AY1/AD5rN4kArt4KTSQJoqhjuy6CaSanyXLMMYiX0lSl3k15CqYu8xaW0LbM HVRcLCfAM7uj7gKRXfLzTIeGDooyLWerbS+AzT3rVXbGFOEIr6SgDW1KUz/XI3FWXMR9nJ0mm7C8P khv4pGjA6hN6ESFu+elpeF0r3NJkvNIIgRZif6XO3c94mEvma2iOH9y33gIjNeCtlDfaKVBKklKV8 ZfiKsYVhw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fWDpw-0000iq-80; Fri, 22 Jun 2018 04:38:16 +0000 Date: Thu, 21 Jun 2018 21:38:15 -0700 From: Matthew Wilcox To: Nicholas Piggin Cc: linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "Aneesh Kumar K.V" , Thiago Jung Bauermann , Ram Pai , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 13/26] ppc: Convert mmu context allocation to new IDA API Message-ID: <20180622043815.GA31255@bombadil.infradead.org> References: <20180621212835.5636-1-willy@infradead.org> <20180621212835.5636-14-willy@infradead.org> <20180622121511.00ae9d00@roar.ozlabs.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180622121511.00ae9d00@roar.ozlabs.ibm.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 22, 2018 at 12:15:11PM +1000, Nicholas Piggin wrote: > On Thu, 21 Jun 2018 14:28:22 -0700 > Matthew Wilcox wrote: > > static int alloc_context_id(int min_id, int max_id) ... > > - spin_lock(&mmu_context_lock); > > - err = ida_get_new_above(&mmu_context_ida, min_id, &index); > > - spin_unlock(&mmu_context_lock); ... > > @@ -182,13 +148,11 @@ static void destroy_contexts(mm_context_t *ctx) > > { > > int index, context_id; > > > > - spin_lock(&mmu_context_lock); > > for (index = 0; index < ARRAY_SIZE(ctx->extended_id); index++) { > > context_id = ctx->extended_id[index]; > > if (context_id) > > - ida_remove(&mmu_context_ida, context_id); > > + ida_free(&mmu_context_ida, context_id); > > } > > - spin_unlock(&mmu_context_lock); > > } > > > > static void pte_frag_destroy(void *pte_frag) > > This hunk should be okay because the mmu_context_lock does not protect > the extended_id array, right Aneesh? That's my understanding. The code today does this: static inline int alloc_extended_context(struct mm_struct *mm, unsigned long ea) { int context_id; int index = ea >> MAX_EA_BITS_PER_CONTEXT; context_id = hash__alloc_context_id(); if (context_id < 0) return context_id; VM_WARN_ON(mm->context.extended_id[index]); mm->context.extended_id[index] = context_id; so it's not currently protected by this lock. I suppose we are currently protected from destroy_contexts() being called twice simultaneously, but you'll notice that we don't zero the array elements in destroy_contexts(), so if we somehow had a code path which could call it concurrently, we'd be seeing warnings when the second caller tried to remove the context IDs from the IDA. I deduced that something else must be preventing this situation from occurring (like, oh i don't know, this function only being called on process exit, so implicitly only called once per context). > Reviewed-by: Nicholas Piggin Thanks.