Received: by 10.192.165.148 with SMTP id m20csp4447950imm; Tue, 8 May 2018 08:36:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrEn7cRXKoUWSr7Ko1dbKglGx1XNABWPBMAdiaQ7+GM0us605DtIIdD0pYHyWNA+C5KcJvV X-Received: by 10.98.29.82 with SMTP id d79mr40540633pfd.230.1525793765715; Tue, 08 May 2018 08:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525793765; cv=none; d=google.com; s=arc-20160816; b=1BHloUx/iWsQh120Mq/V9Lb+93K/YGLDiBvLy6OZ5MKHK3wc+G09JYo+wcj4TiBoVp 3e+H137yxOGzpBZx3Qx07BhCOdjx18ztC/jRbQuBblz8j5bPXEe7UexvHCld4SuvJPgS FdGPJP3ZIyUdYm1N6E8IBYcG1rXIPD+xfiN2YluToAJuLPMGSIJ4ivxvJVPhloWs3fws Zkx2R1GwUZ7DzJm3wkdLncJXUv0DSWJ7N3Fol8az1FTe0xNHvKW84uZHldJbBsbG3xn3 gtCHiH4AYTl4766IakMoz4RyMnxavxsFJ3DGXorLLdncPX18GH8+FPzVxcvGcUKTBWEW WZ0Q== 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:arc-authentication-results; bh=N6nCLvFprlVhTNf5J1T6GN9NK50ME01duTUo3U7AhEM=; b=PsDSnvIdl2pp2+d5LTkxRuBaQM/LjZQgM+1nFIt6XWlSfyHFQf2HJy8ACpAUDmhYTK wgvE9QgcBtBJacYNYOkZLUlX376CQGAxp0OQHf+wp955U9OVwh9IBNeD2Jjmx42hwpVa DFxGd/kGBqvGWp6yg7kxi/E+TSKiNVnL29B7jJFyK01P7QJlId8/s8mT0oiMGBTepRy+ Lczkddr0KdV3DexZzN1IuUV1wNFJlw5e4hF7U9NEAcfFojoJlsXhLe/guvhFb3poIIcN Qa6RVXw3jQWOBJ3eFAr08OJfY7Garry4q2J+IYM23qZaQ1/HCaul3j5E5pGuX6CAQoMo CF1A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22-v6si24015797plr.207.2018.05.08.08.35.51; Tue, 08 May 2018 08:36:05 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933030AbeEHPdW (ORCPT + 99 others); Tue, 8 May 2018 11:33:22 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:54037 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932977AbeEHPdU (ORCPT ); Tue, 8 May 2018 11:33:20 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 249512182F; Tue, 8 May 2018 15:33:19 +0000 (UTC) Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo02-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20ivC8D5GKRK; Tue, 8 May 2018 15:33:19 +0000 (UTC) Received: from [192.168.1.87] (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 11C23213B3; Tue, 8 May 2018 15:33:12 +0000 (UTC) Subject: Re: [PATCH] selftests/memfd: move common code into common.c To: Anders Roxell , David Herrmann Cc: linux-kselftest@vger.kernel.org, Linux Kernel Mailing List , Shuah Khan References: <20180417085936.19512-1-anders.roxell@linaro.org> From: Shuah Khan Message-ID: <9a6dda41-1cbd-d01f-4161-19112712f2e7@kernel.org> Date: Tue, 8 May 2018 09:33:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: 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 Hi David, On 05/08/2018 03:38 AM, Anders Roxell wrote: > On 17 April 2018 at 10:59, Anders Roxell wrote: >> Remove code duplication, in the current code, we move common code for >> memfd to common.c. >> >> The duplicate functions got added in commit 87b2d44026e0 ("selftests: >> add memfd/sealing page-pinning tests") >> >> Signed-off-by: Anders Roxell Okay pull in this patch. I will queue this up for 4.18-rc1. Let me know if you have any objections. >> --- >> tools/testing/selftests/memfd/common.c | 37 +++++++++++++++++++ >> tools/testing/selftests/memfd/common.h | 4 ++ >> tools/testing/selftests/memfd/fuse_test.c | 43 +--------------------- >> tools/testing/selftests/memfd/memfd_test.c | 37 ------------------- >> 4 files changed, 43 insertions(+), 78 deletions(-) >> >> diff --git a/tools/testing/selftests/memfd/common.c b/tools/testing/selftests/memfd/common.c >> index 8eb3d75f6e60..fee1f07828a3 100644 >> --- a/tools/testing/selftests/memfd/common.c >> +++ b/tools/testing/selftests/memfd/common.c >> @@ -44,3 +44,40 @@ int sys_memfd_create(const char *name, unsigned int flags) >> >> return syscall(__NR_memfd_create, name, flags); >> } >> + >> +unsigned int mfd_assert_get_seals(int fd) >> +{ >> + int r; >> + >> + r = fcntl(fd, F_GET_SEALS); >> + if (r < 0) { >> + printf("GET_SEALS(%d) failed: %m\n", fd); >> + abort(); >> + } >> + >> + return (unsigned int)r; >> +} >> + >> +void mfd_assert_add_seals(int fd, unsigned int seals) >> +{ >> + int r; >> + unsigned int s; >> + >> + s = mfd_assert_get_seals(fd); >> + r = fcntl(fd, F_ADD_SEALS, seals); >> + if (r < 0) { >> + printf("ADD_SEALS(%d, %u -> %u) failed: %m\n", fd, s, seals); >> + abort(); >> + } >> +} >> + >> +void mfd_assert_has_seals(int fd, unsigned int seals) >> +{ >> + unsigned int s; >> + >> + s = mfd_assert_get_seals(fd); >> + if (s != seals) { >> + printf("%u != %u = GET_SEALS(%d)\n", seals, s, fd); >> + abort(); >> + } >> +} >> diff --git a/tools/testing/selftests/memfd/common.h b/tools/testing/selftests/memfd/common.h >> index 522d2c630bd8..5c778d15e8c7 100644 >> --- a/tools/testing/selftests/memfd/common.h >> +++ b/tools/testing/selftests/memfd/common.h >> @@ -6,4 +6,8 @@ extern int hugetlbfs_test; >> unsigned long default_huge_page_size(void); >> int sys_memfd_create(const char *name, unsigned int flags); >> >> +void mfd_assert_add_seals(int fd, unsigned int seals); >> +void mfd_assert_has_seals(int fd, unsigned int seals); >> +unsigned int mfd_assert_get_seals(int fd); >> + >> #endif >> diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c >> index b018e835737d..231714615861 100644 >> --- a/tools/testing/selftests/memfd/fuse_test.c >> +++ b/tools/testing/selftests/memfd/fuse_test.c >> @@ -60,49 +60,10 @@ static int mfd_assert_new(const char *name, loff_t sz, unsigned int flags) >> return fd; >> } >> >> -static __u64 mfd_assert_get_seals(int fd) >> +static int mfd_busy_add_seals(int fd, unsigned int seals) >> { >> long r; >> - >> - r = fcntl(fd, F_GET_SEALS); >> - if (r < 0) { >> - printf("GET_SEALS(%d) failed: %m\n", fd); >> - abort(); >> - } >> - >> - return r; >> -} >> - >> -static void mfd_assert_has_seals(int fd, __u64 seals) >> -{ >> - __u64 s; >> - >> - s = mfd_assert_get_seals(fd); >> - if (s != seals) { >> - printf("%llu != %llu = GET_SEALS(%d)\n", >> - (unsigned long long)seals, (unsigned long long)s, fd); >> - abort(); >> - } >> -} >> - >> -static void mfd_assert_add_seals(int fd, __u64 seals) >> -{ >> - long r; >> - __u64 s; >> - >> - s = mfd_assert_get_seals(fd); >> - r = fcntl(fd, F_ADD_SEALS, seals); >> - if (r < 0) { >> - printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", >> - fd, (unsigned long long)s, (unsigned long long)seals); >> - abort(); >> - } >> -} >> - >> -static int mfd_busy_add_seals(int fd, __u64 seals) >> -{ >> - long r; >> - __u64 s; >> + unsigned int s; >> >> r = fcntl(fd, F_GET_SEALS); >> if (r < 0) >> diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c >> index 10baa1652fc2..527789de69b5 100644 >> --- a/tools/testing/selftests/memfd/memfd_test.c >> +++ b/tools/testing/selftests/memfd/memfd_test.c >> @@ -67,43 +67,6 @@ static void mfd_fail_new(const char *name, unsigned int flags) >> } >> } >> >> -static unsigned int mfd_assert_get_seals(int fd) >> -{ >> - int r; >> - >> - r = fcntl(fd, F_GET_SEALS); >> - if (r < 0) { >> - printf("GET_SEALS(%d) failed: %m\n", fd); >> - abort(); >> - } >> - >> - return (unsigned int)r; >> -} >> - >> -static void mfd_assert_has_seals(int fd, unsigned int seals) >> -{ >> - unsigned int s; >> - >> - s = mfd_assert_get_seals(fd); >> - if (s != seals) { >> - printf("%u != %u = GET_SEALS(%d)\n", seals, s, fd); >> - abort(); >> - } >> -} >> - >> -static void mfd_assert_add_seals(int fd, unsigned int seals) >> -{ >> - int r; >> - unsigned int s; >> - >> - s = mfd_assert_get_seals(fd); >> - r = fcntl(fd, F_ADD_SEALS, seals); >> - if (r < 0) { >> - printf("ADD_SEALS(%d, %u -> %u) failed: %m\n", fd, s, seals); >> - abort(); >> - } >> -} >> - >> static void mfd_fail_add_seals(int fd, unsigned int seals) >> { >> int r; >> -- >> 2.17.0 >> > > Ping. > thanks, -- Shuah