From patchwork Tue Sep 27 09:22:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Latvala X-Patchwork-Id: 9351623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C57BD600CB for ; Tue, 27 Sep 2016 09:22:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4DDE29130 for ; Tue, 27 Sep 2016 09:22:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A73BB2916C; Tue, 27 Sep 2016 09:22:44 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4080729130 for ; Tue, 27 Sep 2016 09:22:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 644626E635; Tue, 27 Sep 2016 09:22:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from johanna2.inet.fi (mta-out1.inet.fi [62.71.2.230]) by gabe.freedesktop.org (Postfix) with ESMTP id 4706C6E635 for ; Tue, 27 Sep 2016 09:22:42 +0000 (UTC) RazorGate-KAS: Status: not_detected RazorGate-KAS: Rate: 0 RazorGate-KAS: Envelope from: RazorGate-KAS: Version: 5.5.3 RazorGate-KAS: LuaCore: 80 2014-11-10_18-01-23 260f8afb9361da3c7edfd3a8e3a4ca908191ad29 RazorGate-KAS: Lua profiles 69136 [Nov 12 2014] RazorGate-KAS: Method: none Received: from hufflepuff.adrinael.net (84.250.112.128) by johanna2.inet.fi (9.0.002.03-2-gbe5d057) id 57D29191025C9A9E; Tue, 27 Sep 2016 12:22:41 +0300 Received: from adrinael by hufflepuff.adrinael.net with local (Exim 4.84_2) (envelope-from ) id 1boob3-0004E8-45; Tue, 27 Sep 2016 12:22:41 +0300 From: Petri Latvala To: intel-gfx@lists.freedesktop.org Date: Tue, 27 Sep 2016 12:22:12 +0300 Message-Id: <1474968132-16196-1-git-send-email-petri.latvala@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <20160927075743.GR28107@nuc-i3427.alporthouse.com> References: <20160927075743.GR28107@nuc-i3427.alporthouse.com> Subject: [Intel-gfx] [PATCH i-g-t] lib: Do two writes to /proc/sys/vm/drop_caches again X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The drop_caches sysctl has a max value of 4, so writing 7 to it just fails. Avoid the earlier two-writes problem by opening the fd twice. v2: Don't lseek(), open() twice. (Chris) Signed-off-by: Petri Latvala --- lib/intel_os.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/intel_os.c b/lib/intel_os.c index b9f970d..e448bb4 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -299,11 +299,20 @@ void intel_purge_vm_caches(void) if (fd < 0) return; + /* BIT(2): Be quiet. Cannot be combined with other operations, + * the sysctl has a max value of 4. + */ + igt_ignore_warn(write(fd, "4\n", 2)); + close(fd); + + fd = open("/proc/sys/vm/drop_caches", O_WRONLY); + if (fd < 0) + return; + /* BIT(0): Drop page cache * BIT(1): Drop slab cache - * BIT(2): Be quiet in future */ - igt_ignore_warn(write(fd, "7\n", 2)); + igt_ignore_warn(write(fd, "3\n", 2)); close(fd); }