From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB7E4C433F5 for ; Mon, 11 Apr 2022 01:50:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF5846B0072; Sun, 10 Apr 2022 21:50:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E59616B0073; Sun, 10 Apr 2022 21:50:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF8C96B0074; Sun, 10 Apr 2022 21:50:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id BACEB6B0072 for ; Sun, 10 Apr 2022 21:50:39 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8646A2363B for ; Mon, 11 Apr 2022 01:50:39 +0000 (UTC) X-FDA: 79342918998.07.897CAC3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id AD76140002 for ; Mon, 11 Apr 2022 01:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649641838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=p/2biTee5ymHX+ysegqA4Y0DC0Buk2p13tKUXAlQbkQ=; b=RFbj70rWypPFAy3Jz885UMRIEtFaaSaZHbymzyEKQzv7ODSu+DVQXzHb+R5ocWVafLcbGl zZFS22ZCQNv9sz3XyrC/e8vcwlZu+hcBnz19FAgfyf2AMvLsI8BLnhyr9cT6Gsh+p5v4Zl 1ZnyX0nvZE/LJPNpi9f7JWnRMGzFyWk= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-27-k3QsII90OgelQ4kPgQSxMg-1; Sun, 10 Apr 2022 21:50:37 -0400 X-MC-Unique: k3QsII90OgelQ4kPgQSxMg-1 Received: by mail-lf1-f72.google.com with SMTP id w25-20020a05651234d900b0044023ac3f64so3956772lfr.0 for ; Sun, 10 Apr 2022 18:50:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p/2biTee5ymHX+ysegqA4Y0DC0Buk2p13tKUXAlQbkQ=; b=cZSt+5eosknvIas0FoeGF11w4FclMsAuCIkJC89BbLoUSrTLTutV+Rx/lc83uJjmB5 ny+I1HJvPTO/+ICf9yscSphFl6BiD4nQR1dxqVHB25aIh+fVMcvBG/9PhhvaqRUvW+rx DgD3uoQg/I1xv/mp8c19cxo5NW/my5qT85z/7GB/j9Cr2sWonxkyCSn5ybARsrTt8wNj Uyw0275Dm80YEkXDSZF42MDBdcXMG784ZIznHxP37l2z4WrCf0TePYTwXQIucHwkctPC soyKPXoxLgPiIxfRxvNZmyzv5fNPq83xhNrece5hjx7/Ab8az8C6DgU5pbMwNGIkjEQx eXcA== X-Gm-Message-State: AOAM531sSHp62e1eNWF7qGhGppcK59xFT0RYGjkKrQCrHfX3c4bjHo+z Io8IBLS7Heu/77H2D4MhC+tMTF+OTi7wL1NPuDsxwTj9xraiZ22XiUA629U1M885vtXpvyCt2F4 nDYVEwtonJQ== X-Received: by 2002:a05:651c:1543:b0:249:a2bd:4a74 with SMTP id y3-20020a05651c154300b00249a2bd4a74mr19099808ljp.375.1649641835489; Sun, 10 Apr 2022 18:50:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2XKDfuejW16YO+ipmsqqgRU/ZaK3idz6+CJWo+M6ZaMFFXOi4n2r7mCo70yirfrN7aftAXA== X-Received: by 2002:a05:651c:1543:b0:249:a2bd:4a74 with SMTP id y3-20020a05651c154300b00249a2bd4a74mr19099799ljp.375.1649641835212; Sun, 10 Apr 2022 18:50:35 -0700 (PDT) Received: from mjp-Z390-AORUS-MASTER.redhat.com (91-145-109-188.bb.dnainternet.fi. [91.145.109.188]) by smtp.gmail.com with ESMTPSA id t12-20020a2e954c000000b0024b00cc7539sm2898321ljh.109.2022.04.10.18.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 18:50:34 -0700 (PDT) From: mpenttil@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: =?UTF-8?q?Mika=20Penttil=C3=A4?= , Alistair Popple , Ralph Campbell , Vlastimil Babka Subject: [PATCH v7] mm/hmm/test: use char dev with struct device to get device node Date: Mon, 11 Apr 2022 04:50:05 +0300 Message-Id: <20220411015005.23464-1-mpenttil@redhat.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: dsyrz4n713u8mhqme4yeh7dt9a45m6sm Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RFbj70rW; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf17.hostedemail.com: domain of mpenttil@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=mpenttil@redhat.com X-Rspamd-Queue-Id: AD76140002 X-HE-Tag: 1649641838-852039 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Mika Penttilä HMM selftests use an in-kernel pseudo device to emulate device private memory. The pseudo device registers a major device range for two pseudo device instances. User space has a script that reads /proc/devices in order to find the assigned major number, and sends that to mknod(1), once for each node. Change this to properly use cdev and struct device APIs. Delete the /proc/devices parsing from the user-space test script, now that it is unnecessary. Also, deleted an unused field in struct dmirror_device: devmem. Signed-off-by: Mika Penttilä Reviewed-by: John Hubbard Reviewed-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Cc: Alistair Popple Cc: Ralph Campbell Cc: Vlastimil Babka --- v7: - collected more Review-by's v6: - remove device names array - check return value of dev_set_name() v5: - fix whitespace . delete unused structure field v4: - fix commit log v3: - use cdev_device_add() instead of miscdevice v2: - Cleanups per review comments from John Hubbard - Added Tested-by and Ccs lib/test_hmm.c | 13 ++++++++++--- tools/testing/selftests/vm/test_hmm.sh | 6 ------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index cfe632047839..7d1f98bc9c9a 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -86,7 +86,7 @@ struct dmirror_chunk { */ struct dmirror_device { struct cdev cdevice; - struct hmm_devmem *devmem; + struct device device; unsigned int devmem_capacity; unsigned int devmem_count; @@ -1227,7 +1227,14 @@ static int dmirror_device_init(struct dmirror_device *mdevice, int id) cdev_init(&mdevice->cdevice, &dmirror_fops); mdevice->cdevice.owner = THIS_MODULE; - ret = cdev_add(&mdevice->cdevice, dev, 1); + device_initialize(&mdevice->device); + mdevice->device.devt = dev; + + ret = dev_set_name(&mdevice->device, "hmm_dmirror%u", id); + if (ret) + return ret; + + ret = cdev_device_add(&mdevice->cdevice, &mdevice->device); if (ret) return ret; @@ -1254,7 +1261,7 @@ static void dmirror_device_remove(struct dmirror_device *mdevice) kfree(mdevice->devmem_chunks); } - cdev_del(&mdevice->cdevice); + cdev_device_del(&mdevice->cdevice, &mdevice->device); } static int __init hmm_dmirror_init(void) diff --git a/tools/testing/selftests/vm/test_hmm.sh b/tools/testing/selftests/vm/test_hmm.sh index 0647b525a625..69f5889f8575 100755 --- a/tools/testing/selftests/vm/test_hmm.sh +++ b/tools/testing/selftests/vm/test_hmm.sh @@ -41,17 +41,11 @@ check_test_requirements() load_driver() { modprobe $DRIVER > /dev/null 2>&1 - if [ $? == 0 ]; then - major=$(awk "\$2==\"HMM_DMIRROR\" {print \$1}" /proc/devices) - mknod /dev/hmm_dmirror0 c $major 0 - mknod /dev/hmm_dmirror1 c $major 1 - fi } unload_driver() { modprobe -r $DRIVER > /dev/null 2>&1 - rm -f /dev/hmm_dmirror? } run_smoke() -- 2.17.1