Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp95755imm; Thu, 21 Jun 2018 14:36:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKcqemMFriCnLdu96Ql6L93/zQMYXibHHfQJ3sN/3CwsWprb0BovwATO6v31lHEoUMt7m45 X-Received: by 2002:a17:902:201:: with SMTP id 1-v6mr24911057plc.310.1529616982758; Thu, 21 Jun 2018 14:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529616982; cv=none; d=google.com; s=arc-20160816; b=N1CqkPBWImYfSC7Sgtm4jDKhkT6UtVqoQaefObnQFzN6vcC4AsHIQDoj8xIALqXB7A lH4TMS+6lGnhJTyK4Ff1Lrz/6YF14wVpQJX6gTm8C5vtV+8LBnmTPe8VTnHyRKc21pIB XHEQZAs7pCUPkfYHundYh2eT6lbFNXt/qHkyAQKZIbheq5W3Wrj75Yp5ON+rSUCjHEe8 xMm6O8cEinuzyPjktNeAsDLPg+MgGs22sluQKyskHc7BqrKyFvrvle9kwx7dRAQRWiHA OlCEwM76HPrw00RmTLhP/2/7zXSeqLwmK953cWnMJNy32DRJLifcmSk7TRP5FdQDG7qO KjxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=he4LchhH0ZhNYXo30SJP2NvkEmGGjaOKw+GZ4cMdmL8=; b=a3Wss6Y8E3u2azmwiTujoNYFRmtVO33lT9hQegP875dPINsu4A1+O5I9BbBJ6rIatI XnJ4605JnlxTxxkpqO6dKH93Wm//LpEUtvgA/Q056g8RycWx9GbaW4jeFdyJDYEfD6iu 806LuMj0URFVoNsvMBJW13XU+2Tvid7XHDQfK29Z3Ebs0emRFpK5tqmiphMJxOntw5MT F+U/UW/BYVYk4uiR8C0j0H6lFO7S+MusQmI6vgKYh7mYLjU07XRvBkh8osq5PEgKcGu5 tdswWFGfE5PiRul3Pc54pvhkyX3RTdOm2mv2fbzyGcOnpYvFg4PEO+rgHpYJC8MlgHNc fJqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XVRIEm1B; 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 q186-v6si4638051pga.322.2018.06.21.14.36.08; Thu, 21 Jun 2018 14:36:22 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XVRIEm1B; 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 S934028AbeFUVcx (ORCPT + 99 others); Thu, 21 Jun 2018 17:32:53 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41808 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933968AbeFUV3K (ORCPT ); Thu, 21 Jun 2018 17:29:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: 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=he4LchhH0ZhNYXo30SJP2NvkEmGGjaOKw+GZ4cMdmL8=; b=XVRIEm1B2Wkjk8vJ5JjSNvLyB LCcqYs7RQk5OigRzP6cdY40qaUpvXupabrU0SvwmCQ82Ad4A6C5yuiy3rjTW/QtclCovATwl0IaTT tyuU1PeuyHfulaxH9JHoPbWdXUryn6qtplBQlYLvJUkabfzWI/nLhrD8nO+sBzf8TUi2WCGcL6Ewe rT83JmW/g4BFURcBJNwirrSvo9mGQuweQBupmW1zfHSm/go7/Znqx7+iLc2z6+nPG2aHB9+T5uw1y FhS+XeyGtK49arxt3anwJIOcj/jMJwUHeMMbQpuQYklXTem08pW3vSFvp+f4G74aE/PW7DXibmosg 5RQ70FqXA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW78g-0001cb-HD; Thu, 21 Jun 2018 21:29:10 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Andrew Morton Subject: [PATCH 20/26] idr-test: Convert ida_check_nomem to new API Date: Thu, 21 Jun 2018 14:28:29 -0700 Message-Id: <20180621212835.5636-21-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180621212835.5636-1-willy@infradead.org> References: <20180621212835.5636-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can't move this test to kernel space because there's no way to force kmalloc to fail. But we can use the new API and check this works when the test is in userspace. Signed-off-by: Matthew Wilcox --- tools/testing/radix-tree/idr-test.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c index 604b51dc9b38..0f557784327d 100644 --- a/tools/testing/radix-tree/idr-test.c +++ b/tools/testing/radix-tree/idr-test.c @@ -320,19 +320,20 @@ void ida_dump(struct ida *); /* * Check that we get the correct error when we run out of memory doing - * allocations. To ensure we run out of memory, just "forget" to preload. + * allocations. In userspace, GFP_NOWAIT will always fail an allocation. * The first test is for not having a bitmap available, and the second test * is for not being able to allocate a level of the radix tree. */ void ida_check_nomem(void) { DEFINE_IDA(ida); - int id, err; + int id; - err = ida_get_new_above(&ida, 256, &id); - assert(err == -EAGAIN); - err = ida_get_new_above(&ida, 1UL << 30, &id); - assert(err == -EAGAIN); + id = ida_alloc_min(&ida, 256, GFP_NOWAIT); + IDA_BUG_ON(&ida, id != -ENOMEM); + id = ida_alloc_min(&ida, 1UL << 30, GFP_NOWAIT); + IDA_BUG_ON(&ida, id != -ENOMEM); + IDA_BUG_ON(&ida, !ida_is_empty(&ida)); } /* -- 2.17.1