Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1963609ybg; Thu, 30 Jul 2020 07:12:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU0xc1epDW7ieJFkN04nsxOnveBWOwN7rxIVPMLVg9devp//ra2GRrEJkJ8aPrvUjeidmz X-Received: by 2002:a50:e617:: with SMTP id y23mr2857178edm.47.1596118365896; Thu, 30 Jul 2020 07:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596118365; cv=none; d=google.com; s=arc-20160816; b=TrtSSzPtIrxKS7thV+4s+5oQ9RN4pXa4FwevDVzTWUkhZZsYEOCU31lpPSlR3c+jHG iAyHefO6Pth4Aln/BryHLPyIu+oq47mSdUTJyifunn49N2PIshyAoLh27d4arIB0O2dj az7nSdeDBvvAjtXRbw2tb3a3ZAm2uT6uS2vFEv7PnyzmrqEA6VoYtIPMEknElApuQB7+ SD6NGWGWGbA2nVaR0hyiMd+smSE1XPmhAn7BvXYLrTTrxBEInuUtHZkx0FL3fTI5kxvg u2tgCZ3STF6g5Qw96vpCbeLAUTdjSpBPEq0tfSz81OZ4ZSVyBZ2/taMe/qL4Mj7cqsTf EuOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=DnfYl9fxUY7keR3eWpMl8pU9LaS8cToUOsjGYOVbOm4=; b=V4gDINmFZr15cpTkWa3LX/vcAQhOrGHUIOttY8+zy06KkzJrA54/LHWbx5Tid4B2pC DbkKoGEsvIB+OHg9nZW1w8RC4EYt1OD3E9W59LlAog/XlUFQ/cJgc+KBWT+LcEJEqSVv C7a8BwDaIC56CStFL4ru1549QmKznxnLs3PIQNmOhXfw+EZPH0L0TKoXS+Ng+moHegex svhAZ+1xu42QFBKYulhEg1GtoSxcBkAwO4UkxTSUZHCFHzDGjq5fPDe/8FJ3Yzvb3NWJ dcMJlSvlg5JifIrjlYJKDBQi6K8tHQnYi8iCCzudgU0SElDYufS5z7GOdEJCW9kdzRqd 0Qxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt10si2958757ejb.491.2020.07.30.07.12.23; Thu, 30 Jul 2020 07:12:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729092AbgG3OMO (ORCPT + 99 others); Thu, 30 Jul 2020 10:12:14 -0400 Received: from relay.sw.ru ([185.231.240.75]:33850 "EHLO relay3.sw.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728092AbgG3OMN (ORCPT ); Thu, 30 Jul 2020 10:12:13 -0400 Received: from [192.168.15.64] by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1k19Hn-0004AI-BI; Thu, 30 Jul 2020 17:11:55 +0300 Subject: Re: [PATCH 09/23] ns: Introduce ns_idr to be able to iterate all allocated namespaces in the system To: Matthew Wilcox Cc: viro@zeniv.linux.org.uk, adobriyan@gmail.com, davem@davemloft.net, ebiederm@xmission.com, akpm@linux-foundation.org, christian.brauner@ubuntu.com, areber@redhat.com, serge@hallyn.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org References: <159611007271.535980.15362304262237658692.stgit@localhost.localdomain> <159611040870.535980.13460189038999722608.stgit@localhost.localdomain> <20200730122319.GC23808@casper.infradead.org> <485c01e6-a4ee-5076-878e-6303e6d8d5f3@virtuozzo.com> <20200730135640.GE23808@casper.infradead.org> From: Kirill Tkhai Message-ID: <1e41ae9d-9c3d-1c4a-d49e-b7f660ce99f7@virtuozzo.com> Date: Thu, 30 Jul 2020 17:12:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200730135640.GE23808@casper.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30.07.2020 16:56, Matthew Wilcox wrote: > On Thu, Jul 30, 2020 at 04:32:22PM +0300, Kirill Tkhai wrote: >> On 30.07.2020 15:23, Matthew Wilcox wrote: >>> xa_erase_irqsave(); >> >> static inline void *xa_erase_irqsave(struct xarray *xa, unsigned long index) >> { >> unsigned long flags; >> void *entry; >> >> xa_lock_irqsave(xa, flags); >> entry = __xa_erase(xa, index); >> xa_unlock_irqrestore(xa, flags); >> >> return entry; >> } > > was there a question here? No, I just I will add this in separate patch. >>>> +struct ns_common *ns_get_next(unsigned int *id) >>>> +{ >>>> + struct ns_common *ns; >>>> + >>>> + if (*id < PROC_NS_MIN_INO - 1) >>>> + *id = PROC_NS_MIN_INO - 1; >>>> + >>>> + *id += 1; >>>> + *id -= PROC_NS_MIN_INO; >>>> + >>>> + rcu_read_lock(); >>>> + do { >>>> + ns = idr_get_next(&ns_idr, id); >>>> + if (!ns) >>>> + break; >>> >>> xa_find_after(); >>> >>> You'll want a temporary unsigned long to work with ... >>> >>>> + if (!refcount_inc_not_zero(&ns->count)) { >>>> + ns = NULL; >>>> + *id += 1; >>> >>> you won't need this increment. >> >> Why? I don't see a way xarray allows to avoid this. > > It's embedded in xa_find_after(). How is it embedded to check ns->count that it knows nothing?