From patchwork Thu Jun 3 21:25:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Schutt X-Patchwork-Id: 104177 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o53LORbm013560 for ; Thu, 3 Jun 2010 21:26:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753205Ab0FCV0n (ORCPT ); Thu, 3 Jun 2010 17:26:43 -0400 Received: from sentry-three.sandia.gov ([132.175.109.17]:37195 "EHLO sentry-three.sandia.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751776Ab0FCV0m (ORCPT ); Thu, 3 Jun 2010 17:26:42 -0400 X-WSS-ID: 0L3GJKE-0C-27U-02 X-M-MSG: Received: from sentry.sandia.gov (sentry.sandia.gov [132.175.109.20]) by sentry-three.sandia.gov (Postfix) with ESMTP id 17B95491DC7; Thu, 3 Jun 2010 15:26:37 -0600 (MDT) Received: from [132.175.109.1] by sentry.sandia.gov with ESMTP (SMTP Relay 01 (Email Firewall v6.3.2)); Thu, 03 Jun 2010 15:26:29 -0600 X-Server-Uuid: AF72F651-81B1-4134-BA8C-A8E1A4E620FF Received: from localhost.localdomain (jast03.sandia.gov [134.253.4.114]) by mailgate.sandia.gov (8.14.4/8.14.4) with ESMTP id o53LQLnV016397; Thu, 3 Jun 2010 15:26:21 -0600 From: "Jim Schutt" To: ceph-devel@vger.kernel.org cc: sage@newdream.net, "Jim Schutt" Subject: [RFC PATCH] msgr: Prevent unbounded use of bufferlist memory by throttling incoming messages. Date: Thu, 3 Jun 2010 15:25:57 -0600 Message-ID: <1275600357-11367-1-git-send-email-jaschut@sandia.gov> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <16744_1275600306_o53LOfiY016748_1275600252.4800.13.camel@sale659.sandia.gov> References: <16744_1275600306_o53LOfiY016748_1275600252.4800.13.camel@sale659.sandia.gov> X-PMX-Version: 5.5.9.395186, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2010.6.3.211514 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, TO_NO_NAME 0, __FRAUD_BADTHINGS 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __URI_NS ' X-TMWD-Spam-Summary: TS=20100603212632; ID=1; SEV=2.3.1; DFV=B2010060321; IFV=NA; AIF=B2010060321; RPD=5.03.0010; ENG=NA; RPDID=7374723D303030312E30413031303230342E34433038314530392E303032463A534346535441543838363133332C73733D312C6667733D30; CAT=NONE; CON=NONE; SIG=AAABAKR1FwAAAAAAAAAAAAAAAAAAAH0= X-MMS-Spam-Filter-ID: B2010060321_5.03.0010 MIME-Version: 1.0 X-WSS-ID: 6016C18F2GW492696-01-01 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 03 Jun 2010 21:26:44 +0000 (UTC) diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index a7fb18d..11163e3 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -1750,6 +1750,20 @@ Message *SimpleMessenger::Pipe::read_message() unsigned data_off = le32_to_cpu(header.data_off); if (data_len) { int left = data_len; + int throttled = 0; + + while (buffer_total_alloc.read() + data_len > (64*1024*1024)) { + struct timespec sleepy_time = {0, (1000 * 1000)}; // 1 msec + if (!throttled) + dout(4) << " pipe reader paused" << "; buffer_total_alloc " + << buffer_total_alloc.read() << dendl; + ::nanosleep(&sleepy_time, 0); + throttled++; + } + if (throttled) + dout(4) << " pipe reader unpaused; buffer_total_alloc " + << buffer_total_alloc.read() << dendl; + if (data_off & ~PAGE_MASK) { // head int head = MIN(PAGE_SIZE - (data_off & ~PAGE_MASK),