Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751850AbdIVFYO (ORCPT ); Fri, 22 Sep 2017 01:24:14 -0400 Received: from mail-qt0-f172.google.com ([209.85.216.172]:44704 "EHLO mail-qt0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750839AbdIVFYM (ORCPT ); Fri, 22 Sep 2017 01:24:12 -0400 X-Google-Smtp-Source: AOwi7QDiuoueIngE8JV54cSrLQL4HezRrKVrt6Mus7G7klOzhlltw/o5blYe1ZjJKcTVksBmFTPoJw== Date: Fri, 22 Sep 2017 01:24:10 -0400 Message-ID: <87a81nxq4l.wl-v.mayatskih@gmail.com> From: Vitaly Mayatskikh To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jens Axboe Subject: Re: [PATCH] fix unbalanced page refcounting in bio_map_user_iov In-Reply-To: <87bmm3xqds.wl-v.mayatskih@gmail.com> References: <87bmm3xqds.wl-v.mayatskih@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/25.3 Mule/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2659 Lines: 89 Reproducer (needs SCSI disk): #include #include #include #include #include #include #include #include #include #define NR_IOS 10000 #define NR_IOVECS 8 #define SG_IO 0x2285 int main(int argc, char *argv[]) { int fd, i, j; unsigned char *buf, *ptr, cdb[10]; sg_io_hdr_t io_hdr; sg_iovec_t iovec[NR_IOVECS]; if (argc < 2) { printf("Run: %s \n", argv[0]); exit(1); } buf = ptr = memalign(4096, NR_IOS * NR_IOVECS * 512); if (!buf) { printf("can't alloc memory\n"); exit(1); } fd = open(argv[1], 0); if (fd < 0) { printf("open %s failed: %d (%s)\n", argv[1], errno, strerror(errno)); exit(1); } io_hdr.interface_id = 'S'; io_hdr.cmd_len = sizeof(cdb); io_hdr.cmdp = cdb; io_hdr.dxfer_direction = SG_DXFER_FROM_DEV; io_hdr.dxfer_len = 512 * NR_IOVECS; io_hdr.dxferp = iovec; io_hdr.iovec_count = NR_IOVECS; cdb[0] = 0x28; // READ10 cdb[8] = NR_IOVECS; // sectors for (j = 0; j < NR_IOS; j++, ptr += 512) { for (i = 0; i < NR_IOVECS; i++) { iovec[i].iov_base = ptr; iovec[i].iov_len = 512; } if (ioctl(fd, SG_IO, &io_hdr)) { printf("IOCTL failed: %d (%s)\n", errno, strerror(errno)); exit(1); } } free(buf); close(fd); return 0; } # free -m total used free shared buff/cache available Mem: 3827 46 3601 0 178 3568 Swap: 0 0 0 # ./sgio-leak /dev/sdd # free -m total used free shared buff/cache available Mem: 3827 85 3562 0 178 3529 Swap: 0 0 0 [root@node-A ~]# free -m total used free shared buff/cache available Mem: 3827 85 3628 0 113 3561 Swap: 0 0 0 # ./sgio-leak /dev/sdd # free -m total used free shared buff/cache available Mem: 3827 124 3589 0 113 3523 Swap: 0 0 0 -- wbr, Vitaly