From owner-freebsd-hackers@freebsd.org Wed Jul 11 23:45:43 2018 Return-Path: Delivered-To: freebsd-hackers@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 D4BE81030641 for ; Wed, 11 Jul 2018 23:45:42 +0000 (UTC) (envelope-from steevanxperia@gmail.com) Received: from mail-oi0-x236.google.com (mail-oi0-x236.google.com [IPv6:2607:f8b0:4003:c06::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5EF1F8E3F6 for ; Wed, 11 Jul 2018 23:45:42 +0000 (UTC) (envelope-from steevanxperia@gmail.com) Received: by mail-oi0-x236.google.com with SMTP id q11-v6so26919888oic.12 for ; Wed, 11 Jul 2018 16:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lzSser86VqEoks23/sqyajK5rjDhKLRATJ1K2TtANXc=; b=ZMz7PqKAfdB+Tao+oXozuP+MXWJJZ+XJkf8RzqqfOTcWrI8VMbLOrnfI12sod4ILh3 be5DOQ6yWQMGZTD58uIfPRBYZkgW4GdBrW/gcyqcAVwAzY/xNAeEmL/mrUPgPZtqLr04 0BA09y7y++aT64oBDyC/SS0eoLUtpOyHjkJiJ62sXSiMFegwC8y9OMLoiFZ1EIafiI1F bRN2iVhoxvgx3s3aRer07sOIv5cM58yxQontsoPdm7jZkMWP1G0uhWB0F0zSGxSHICgn BzW+cJ1CkRdS5FDq/KZtgy0mF0gDjK/KFEWN3tc4cVW81guvPMgbQkHHGk6tCvM2wASV 1YGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lzSser86VqEoks23/sqyajK5rjDhKLRATJ1K2TtANXc=; b=qsMUxtE4weohqoryISzMlIdvEjymlyQBWys/LQCLNeEShPREoYA5UaFXhdD8Ms/sMa SGRq+12pJW/GBDgmVLGYz00NKmod0b0HOidTwA8OTOLSIAwTZTFDbedEhnddTC0Ozdvy kMaFeW0gcVhyj7NbBYQJ+yl0S901Awv6C4rDOOnwK222Ts7rypADhxDhuA5Hiijcav1D aNjPR9fwgVoMnm0mQ16CDJxf90J/1Tjw8Dfwl3PfefIlhpmf0Yr0+L2WH60ZuaWfdJ2r /KsBADWk2JyVZGFu0Z+5NQUmWXL1Zew96NisdB//VNqF7vIrYvIFH7CCXFAI2OC/zAE5 /SpA== X-Gm-Message-State: AOUpUlHvubIOVy2uzyL5rLTs8JRqxqSo3sDQ7Ghab8cwOSfkmCFl02tM VHNt17R7C2QD4XIdlb6VKbdTfG1mwmB4XAV1rXI= X-Google-Smtp-Source: AAOMgpfGCB9ni9q8lbqo9L7vmc+3ldoi7MUtWlfW79k9Ly+T+0IWwquwBvWN2JbiOZIJmYgWfOrbA33U40KtJMjdNv0= X-Received: by 2002:aca:4e4d:: with SMTP id c74-v6mr811539oib.16.1531352741554; Wed, 11 Jul 2018 16:45:41 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:5bd6:0:0:0:0:0 with HTTP; Wed, 11 Jul 2018 16:45:41 -0700 (PDT) In-Reply-To: <03274bb2-87b1-ab32-ee15-81e83b6f6bdd@cs.duke.edu> References: <2ae78782-6cca-452e-d004-3999885ae4e0@cs.duke.edu> <03274bb2-87b1-ab32-ee15-81e83b6f6bdd@cs.duke.edu> From: Steevan Rodrigues Date: Thu, 12 Jul 2018 05:15:41 +0530 Message-ID: Subject: Re: high CPU usage in FreeBSD for a PCIe card driver To: Andrew Gallatin Cc: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2018 23:45:43 -0000 Thanks for confirming it. Yes I do very frequent device ioctl calls . Regards, Steevan On Wed, Jul 11, 2018 at 11:52 PM, Andrew Gallatin wrote: > On 07/11/18 07:46, Steevan Rodrigues wrote: > >> Hello Andrew, >> >> Sorry to bother you. I am working on this problem again after a break of >> few days. >> I ran following command to get lock statistics when I run my userspace >> application on a 12 core 24 thread server PC. >> From this data below to looks like my driver is causing a contention on >> a kernel lock (pmap ). Am I right ? >> >> lockstat -x aggsize=4m -D 20 sleep 10 >> >> Adaptive mutex spin: 1122679 events in 10.013 seconds (112121 events/sec) >> >> Count indv cuml rcnt nsec Lock Caller >> ------------------------------------------------------------ >> ------------------- >> 1089662 97% 97% 0.00 65375 pmap pmap_extract+0x1d2 >> 31805 3% 100% 0.00 14881 cdev devvn_refthread+0x142 >> > > > Yes. You can get more information if you use the -s 10 argument to > lockstat. That way, you'll see what's calling pmap_extract. > > Are you doing frequent device ioctls? > > > Drew >