From owner-freebsd-current@freebsd.org Wed Oct 17 14:06:28 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0588A10D63D1 for ; Wed, 17 Oct 2018 14:06:28 +0000 (UTC) (envelope-from ciunas.bennett@intel.com) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "fmsmga101.fm.intel.com", Issuer "COMODO RSA Organization Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 72CB98182C for ; Wed, 17 Oct 2018 14:06:27 +0000 (UTC) (envelope-from ciunas.bennett@intel.com) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2018 07:06:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,392,1534834800"; d="c'?scan'208,217";a="82183476" Received: from irsmsx154.ger.corp.intel.com ([163.33.192.96]) by orsmga008.jf.intel.com with ESMTP; 17 Oct 2018 07:06:19 -0700 Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by IRSMSX154.ger.corp.intel.com (163.33.192.96) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 17 Oct 2018 15:06:18 +0100 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.4]) by IRSMSX156.ger.corp.intel.com ([169.254.3.178]) with mapi id 14.03.0319.002; Wed, 17 Oct 2018 15:06:17 +0100 From: "Bennett, Ciunas" To: "freebsd-current@freebsd.org" CC: "Bennett, Ciunas" Subject: contigmalloc uses up all free memory. Thread-Topic: contigmalloc uses up all free memory. Thread-Index: AdRmIn9wFVlSeEKdRcag0Hmh1d8U9w== Date: Wed, 17 Oct 2018 14:06:17 +0000 Message-ID: <770FD3608C9E864796AB46CB37B561B1BDFCD284@IRSMSX101.ger.corp.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjYwNjRkOTQtNTcxYS00YWYyLWExM2QtNDg5MjkwZDY5MzQzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTTB1Z1wvaXFGUnNFTTdDbGFlOVF4RWZ2ZXVrckQ1ZzFtM0ptbTNzUDlHSWpMMk5MTUpjNmJIMmRyNVhBdjI5Z0gifQ== x-originating-ip: [163.33.239.181] Content-Type: multipart/mixed; boundary="_005_770FD3608C9E864796AB46CB37B561B1BDFCD284IRSMSX101gercor_" MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 17 Oct 2018 14:32:40 +0000 X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Oct 2018 14:06:28 -0000 --_005_770FD3608C9E864796AB46CB37B561B1BDFCD284IRSMSX101gercor_ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hello, I have encountered an issue with a kernel application that I have written, the application allocates and deallocates contiguous memory using contigma= lloc() and contigfree(). The application will fail after a period of time because there is not enoug= h free contiguous memory left. There could be an issue with the freeing of memory when using the contigfre= e() function. I have attached a simplified version of the application. The resulting kernel module just allocates contiguous memory and then frees= the memory using contigfree(); This allocation is done in a loop and the attached src code triggers the i= ssue. After a period of time when running the application multiple times, the ker= nel reports that there is no available memory and fails with allocation. I can see that the amount of free memory is decreasing in correlation to ho= w many times I run the application by using DDB and printing out freepages using "= show freepages" I run the application in a loop using a shell script where I kldload then k= ldunload multiple times (script runs up to 1000000) The application can take 20 to over 60 minutes to trigger the issue and run= out of memory but can take longer also. I am running the application on -> FreeBSD 12.0-ALPHA9 also tested on 11.2 VM with 2 Gb of ram. Allocating one cpu core. Running on an Intel(R) Xeon(R) CPU E5-2658 v2 @ 2.40GH using Ubuntu 16.04 h= ost. I have attached the test kernel application and a Makefile. Thanks, Ciunas. -------------------------------------------------------------- Intel Research and Development Ireland Limited Registered in Ireland Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263 This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact = the sender and delete all copies. --_005_770FD3608C9E864796AB46CB37B561B1BDFCD284IRSMSX101gercor_ Content-Type: text/plain; name="k_memory_contig.c" Content-Description: k_memory_contig.c Content-Disposition: attachment; filename="k_memory_contig.c"; size=1866; creation-date="Wed, 17 Oct 2018 13:33:35 GMT"; modification-date="Wed, 17 Oct 2018 13:33:35 GMT" Content-Transfer-Encoding: base64 I2luY2x1ZGUgPHN5cy9wYXJhbS5oPgojaW5jbHVkZSA8c3lzL2NvbmYuaD4KI2luY2x1ZGUgPHN5 cy9rZXJuZWwuaD4KI2luY2x1ZGUgPHN5cy9tYWxsb2MuaD4KI2luY2x1ZGUgPHN5cy9tb2R1bGUu aD4KI2luY2x1ZGUgPHN5cy9zeXN0bS5oPgoKI2RlZmluZSBERVZfTUVN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gICAgY29udGlnZnJlZShtZW1fYmxvY2tzW2ldLCBhcnJheVtpXSwgVEVT VF9NRU0pOwoKICAgIGZvciAoaSA9IDA7IGkgPCAxMDsgaSsrKQogICAgewogICAgICAgIG1lbV9i bG9ja3NbaV0gPSBjb250aWdtYWxsb2MoYXJyYXkxW2ldLCBURVNUX01FTSwgMCwgMCwgfjAsIFBB R0VfU0laRSwgMCk7CiAgICAgICAgaWYgKCFtZW1fYmxvY2tzW2ldKQogICAgICAgIHsKICAgICAg ICAgICAgcHJpbnRmKCIlczolZCBVbmFibGUgdG8gYWxsb2NhdGUgY29udGlndW91cyBtZW1vcnkg c2xhYiBcbiIsIF9fZnVuY19fLAogICAgICAgICAgICAgICAgICAgX19MSU5FX18pOwogICAgICAg ICAgICByZXR1cm4gLTE7CiAgICAgICAgfQogICAgfQoKICAgIGZvciAoaSA9IDA7IGkgPCAxMDsg aSsrKQogICAgICAgIGNvbnRpZ2ZyZWUobWVtX2Jsb2Nrc1tpXSwgYXJyYXkxW2ldLCBURVNUX01F TSk7CgogICAgcmV0dXJuIDA7Cn0KCnN0YXRpYyBpbnQgbWVtX21vZGV2ZW50KG1vZHVsZV90IG1v ZCBfX3VudXNlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCB0eXBlLAogICAgICAg ICAgICAgICAgICAgICAgICAgICAgdm9pZCAqZGF0YSBfX3VudXNlZCkKewoKICAgIHN3aXRjaCAo dHlwZSkKICAgIHsKICAgICAgICBjYXNlIE1PRF9MT0FEOgogICAgICAgICAgICB0ZXN0X2FwcGxp Y2F0aW9uKCk7CiAgICAgICAgICAgIHJldHVybiAoMCk7CiAgICAgICAgY2FzZSBNT0RfVU5MT0FE OgogICAgICAgICAgICByZXR1cm4gKDApOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHJl dHVybiAoRU9QTk9UU1VQUCk7CiAgICB9Cn0KCkRFVl9NT0RVTEUodGVzdF9tZW0sIG1lbV9tb2Rl dmVudCwgTlVMTCk7Ck1PRFVMRV9WRVJTSU9OKHRlc3RfbWVtLCAxKTsK --_005_770FD3608C9E864796AB46CB37B561B1BDFCD284IRSMSX101gercor_ Content-Type: application/octet-stream; name="Makefile" Content-Description: Makefile Content-Disposition: attachment; filename="Makefile"; size=67; creation-date="Wed, 17 Oct 2018 13:33:25 GMT"; modification-date="Wed, 17 Oct 2018 13:33:04 GMT" Content-Transfer-Encoding: base64 S01PRD0Ja19tZW1vcnlfYXBwClNSQ1M9CWtfbWVtb3J5X2NvbnRpZy5jCgouaW5jbHVkZSA8YnNk Lmttb2QubWs+Cg== --_005_770FD3608C9E864796AB46CB37B561B1BDFCD284IRSMSX101gercor_--