From patchwork Sun Aug 19 04:01:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ocean He X-Patchwork-Id: 10569661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E82081390 for ; Sun, 19 Aug 2018 04:01:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C96C829B5B for ; Sun, 19 Aug 2018 04:01:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB8D529B63; Sun, 19 Aug 2018 04:01:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A23EB29B5B for ; Sun, 19 Aug 2018 04:01:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E10C2210F4BAD; Sat, 18 Aug 2018 21:01:41 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400d:c0d::243; helo=mail-qt0-x243.google.com; envelope-from=oceanhehy@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-qt0-x243.google.com (mail-qt0-x243.google.com [IPv6:2607:f8b0:400d:c0d::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8C2BF210EE4F8 for ; Sat, 18 Aug 2018 21:01:40 -0700 (PDT) Received: by mail-qt0-x243.google.com with SMTP id m13-v6so12952458qth.1 for ; Sat, 18 Aug 2018 21:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5D4YUF+p0alJRPnlxV77AWTJkir6fdQLSR8NBHJS0X4=; b=PVUA79HtoOEBHBuPCziHD/XF9UX3ZpJ3vaV9h+OUl+z5lM8uwrmWSgNNcsKHPouDPC v5GxFyHrruLlumfrc2dZNMggTRhxqIQZPFcLbRAWdEVqxg8nlS7YWsVEiM6Bb2raSCUT c5iMbmLUIW9tlbL10hDi0MejLlpsNu5nnG+SnbD8zpiTR9ugBNvNK+hRzMEViC8sFoMH LawWa9h8lziDqEIJHsfs6PudZ7XSmz8yoAwi/GYu79ZDsnruKTgJTC9DgZWg1LKaZ6uq X2Gwj6ausy+mhqUXrb8TyuRnuaPpH5aT6+Qe9KL1GiDqLfpQg4+7rYMs+GUMc16Fia54 v16w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5D4YUF+p0alJRPnlxV77AWTJkir6fdQLSR8NBHJS0X4=; b=VkEBmKi9XpqH7vMd1q7N4Myzflr9fsYZMInScCmJUbeMXbbp6xRe8tBxfvA5DKLFrw juwZSm4fU5aKD+k6DGlTDC5RF0cPrPuRW94UETvMvwjo2x/zd/ryyeGItTbvfwWj6Nra U+sdIoyeepq8UeCtZPQ0i6QK/snsHTwZtWHyhh6qCmsD6ASkCksHEjV2Vi8al0iMzKH+ DllrjpPjnY9iRMwYzYJmBWTuP2GMqMIv3+C0emT6k25ZHYS+gr0yuM/cCM919gweBM0G lh4v29AloeIoTzMrmBSfLyluxPNcPzlWRn6U0rpLUumNOgM3VA43aog4LcQ3O0a8WySZ rczg== X-Gm-Message-State: AOUpUlGOPLBaG0gD+CvjMCJIaKZ1p5UT/RH5xi400wnCiA+vTTkwaDSY eW0/EIUem606VZUJs70ck24= X-Google-Smtp-Source: AA+uWPy4v3qyWdV/lqnoRf4PnwCFCETwkhjLVfcO8HuJq2vXfnISdurB98EAimeSMz3RMzz08yH+Fg== X-Received: by 2002:a0c:a162:: with SMTP id d89-v6mr36671744qva.198.1534651299429; Sat, 18 Aug 2018 21:01:39 -0700 (PDT) Received: from 192.168.190.131 ([104.237.86.149]) by smtp.gmail.com with ESMTPSA id n186-v6sm3353894qkb.32.2018.08.18.21.01.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Aug 2018 21:01:38 -0700 (PDT) From: Ocean He To: dan.j.williams@intel.com, ross.zwisler@linux.intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com Subject: [PATCH] libnvdimm, region_devs: stop NDD_ALIASING bit test if one test pass Date: Sun, 19 Aug 2018 00:01:28 -0400 Message-Id: <1534651288-30306-1-git-send-email-oceanhehy@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ocean He , linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Ocean He There is no need to finish entire loop to execute NDD_ALIASING bit test against every nvdimm->flags. In practice, all the nd_mapping->nvdimm have the same flags. Because the check of alias is "if (alias)" but not "if (alias == nd_region->ndr_mappings)", there is no function change while just save a few cycles. Signed-off-by: Ocean He --- A test to check if all the nd_mapping->nvdimm have the same flags, using Lenovo ThinkSystem SR630 and 4.18-rc6. # ipmctl show -dimm DimmID Capacity HealthState ActionRequired LockState FWVersion 0x0021 125.7 GiB Healthy 0 Disabled 01.00.00.4888 0x0121 125.7 GiB Healthy 0 Disabled 01.00.00.4888 0x1021 125.7 GiB Healthy 0 Disabled 01.00.00.4888 0x1121 125.7 GiB Healthy 0 Disabled 01.00.00.4888 # ipmctl create -f -goal -socket 0x0 PersistentMemoryType=AppDirect # ipmctl create -f -goal -socket 0x1 PersistentMemoryType=AppDirect # reboot, to make goal configuration take effect. # ndctl create-namespace -r region0 -s 100m -t pmem -m fsdax # ndctl create-namespace -r region1 -s 100m -t pmem -m fsdax # reboot and find all the nd_mapping->nvdimm have the same flags. drivers/nvdimm/region_devs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index ec3543b..fc3bc1c 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -234,8 +234,10 @@ int nd_region_to_nstype(struct nd_region *nd_region) struct nd_mapping *nd_mapping = &nd_region->mapping[i]; struct nvdimm *nvdimm = nd_mapping->nvdimm; - if (test_bit(NDD_ALIASING, &nvdimm->flags)) + if (test_bit(NDD_ALIASING, &nvdimm->flags)) { alias++; + break; + } } if (alias) return ND_DEVICE_NAMESPACE_PMEM;